I'm trying to get all datasources of a rendering, including personalization.

As we are using SXA the datasource strings look like this: local:/Data/Test
What is the best way to get the item from this? Normally the getRenderingDatasource pipeline would handle this, but how do I do this programmatically?

  • Once you have this information, how might you make use of it? Jan 7, 2019 at 16:56

1 Answer 1


It's quite easy:

//inject pipeline manager (instead of ServiceLocator you can use constructor injection if needed)
BaseCorePipelineManager pipelineManager = ServiceLocator.ServiceProvider.GetService<BaseCorePipelineManager>();

//create pipeline arguments where you put data source string
var args = new ResolveRenderingDatasourceArgs(rendering.DataSource);

//run the pipeline
pipelineManager.Run("resolveRenderingDatasource", args);

As an output, you will have either ID or an item path in args.Datasource property.

  • Thanks, this helped me a lot :) But I had to do it this way (although having the correct usings): ServiceLocator.ServiceProvider.GetService(typeof(BaseCorePipelineManager)) as BaseCorePipelineManager Jan 8, 2019 at 13:32
  • Just such using using Microsoft.Extensions.DependencyInjection; and you will be able to use GetService like that: ServiceLocator.ServiceProvider.GetService<BaseCorePipelineManager>(). Jan 8, 2019 at 14:53
  • You will need to add Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions nuget packages for this. Jan 8, 2019 at 14:54
  • I added the first dll, but not the Abstractions one. That explains it. Thanks! Jan 9, 2019 at 11:36

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.