web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Alternative for shared variables in plugin to pass data in context

(0) ShareShare
ReportReport
Posted on by

We have one plugin(i.e. plugin1) which is triggered on update of the Entity A. In Plugin1 we are updating another entity B. On update of Entity B we have 3 plugin registered(Plugin2, Plugin3 and Plugin4). In Plugin 4 we were reading shared variables added in Plugin1. This is working fine in CRM 2011, now we migrated to D365. As change in shared variables in D365, shared variables update of entity 1 will not available to another entity update if Depth is 2. 

Is there any other way to pass variables from 1 entity update plugin to another entity update plugin?

Please advise.

Regards,

Diksha

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    You could create a attribute on Entity B to have the shared variable value. This value will be set by Plugin 1.

    Since Plugin 2,3,4 trigger on Update, they will have access to that attribute.

    If you want to go a bit further with this, you could also think about setting the plugin execution order

    And you could also take advantage of Plugin Execution Order, if you want to lets say pass fro Plugin 1 to 2  and then from 2 to 3 and from 3 to 4.

    "Execution order in plugin specifies the order, also known as rank, that plug-ins are executed within a pipeline stage. Plug-ins registered with an order value of 1 are executed first, followed by plug-ins registered with an order of 2, and so on. However, if there is more than one plug-in in a stage with the same order value, then the plug-in with the earliest compilation date is called first"

    social.microsoft.com/.../execution-order-in-plugin-registration-tool

  • Community Member Profile Picture
    on at

    Hi Kokulan,

    Thanks for suggestion.

    For now we have fixed issue creating new attribute on Entity B. But we have many other plugins so we just want to know if there is any other way to set shared variables. So we can move value stored in shared variable to that parameter of context. If CRM is provides alternative for same please let us know.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    Do you have settings entity in your CRM system, if so you could use setting records as shared variables?

    If you don't already have a settings entity, you can actually create an Entity called shared variable

    You can create fields in it based on the type of value you want to store in shared variables

    You can create the shared variable records and get the record  using GUIDS using Retrieve instead of Retrieve Multiple

    For Example

    SharedVariableOne - has a record in Shared Variable Entity - Created Manually By You

    In your plugin Code, you could create a Property that has the following code

    5076.ScreenClip-_5B00_198_5D00_.png

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    You can improve the Variable Loading time, by having a backing variable as shown below

    8304.ScreenClip-_5B00_199_5D00_.png

    One thing I forgot to mention when you deploy to other environments, you will have to export and import the SharedVariable records as one off thing to maintain the GUID.

  • Shaun W Harvey Profile Picture
    242 on at

    Hi Diksha,

    I have just come across your post regarding this issue.

    Do you have any details as to when this change around Shared Variables took place and what the exact details are.

    Is there any documentation, blog post or something?

    I think I may have come across a very similar issue. Trying to read shared variable set on entity 1 during an another entity update when the depth =2

    Best Regards,

    Shaun

  • Community Member Profile Picture
    on at

    Hi Shaun,

    We facing this issue while migration, we were using same plugin developed for 2011 version. Few of them is not working in D365. We checked the Shared Variables returning undefined. So we searched it on community. We got below reference URL,

    www.magnifez.com/shared-variables-and-impersonation-in-ms-dynamic-crm-plugins-advanced-plugin-concept-part-2

    In last stanza they mentioned that shared variables are changed in D365. So we stored value in field, which passes with parents context.

    Regards,

    Diksha

  • Shaun W Harvey Profile Picture
    242 on at

    Hi Diksha,

    I have found the same post as well. Left a comment to ask how they know about the changes?

    I am more than happy to accept the functionality has changed and I may have to change our plugin code. I'm just curious as to how they know as I can't find any other documentation around this change.

    Thanks,

    Shaun

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ZS-27011425-0 Profile Picture

ZS-27011425-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans