0

I want to access the rendering context in the getLookupSourceItems pipeline.

public void Process(GetLookupSourceItemsArgs args)
{     
    //
    var rc = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull;
    //
}

But I am getting null value in the RenderingContext.

Any suggestions how can I get the rendering context in the getLookupSourceItems pipeline

  • 1
    The reason why you are getting null is because the Rendering Context is getting called after the getLookupSourceItems pipeline. Can you explain a little more on what you are trying? Ideally there should not be a need for getting the Rendering Context in getLookupSourceItems Pipeline as this pipeline is used for setting the data sources in templates. Are you trying to create a custom field? – Sumit Upadhyay Oct 22 at 7:17
  • @sumit yes i am creating a custom field. I need to. Check current rendering’s datasource and then get the field value from the datasource and assign to the custom field – Owais Ahmed Oct 22 at 11:00
  • Then you don't need to call getLookupSourceItems pipeline. You can create the custom item at runtime and then populate the field value by using Security Disabler and assigning the field value like item.Fields["field name"].Value = "your value" – Sumit Upadhyay Oct 22 at 12:13
1

Apologies for the Short answer.

What you can try to implement is to use PageContext.Current.Item which will give you the Current page item or RenderingContext.Current.Rendering.Item

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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