I am trying to get all rendering datasources added to an item. I used the below code

var renderings = InnerItem.Visualization.GetRenderings(InnerItem.Database.Resources.Devices.GetAll().Where(d
    => d.Name.ToLower() == "default").First(), true);

 var renderingReferences = renderings?.Where(r =>!String.IsNullOrWhiteSpace(r.Settings.DataSource)).ToList();

I see that datasources with static path are returned but those datasources for whom the path is like local:/Data/ Teaser 1 are returned empty.

Is there a way to get the value of such datasources(target item id) instead of returning an empty value?

1 Answer 1


If local or page relative SXA data sources are not resolved you need to resolve them manually. Run resolveRenderingDatasource pipeline:

ResolveRenderingDatasourceArgs renderingDatasourceArgs = new ResolveRenderingDatasourceArgs(YOUR_DATA_ROURCE_STRING);
renderingDatasourceArgs.CustomData.Add("contextItem", CONTEXT_ITEM);
CorePipeline.Run("resolveRenderingDatasource", renderingDatasourceArgs);

string resolvedDataSource = renderingDatasourceArgs.Datasource;
  • Thanks @David for your answer. Your code helped me in resolving the issue. Aug 2, 2021 at 9:59
  • 1
    @aruntiwari How were you able to fix this? I am getting the same error but my issue with the above code is that I do not have a value for YOUR_DATA_SOURCE_STRING so that pipeline won't work. From your question it would appear that you would be having the same issue as well? Aug 20, 2021 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.