Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Dynamix Academy / Dynamics 365 CRM Plugin Sha...

Dynamics 365 CRM Plugin Shared Variables – Explained with Example

In this video article, we will learn everything about Dynamics 365 Plugin Shared Variables with examples.

Many times while writing plugins in Dynamics 365 or CRM, you might have faced a situation in which, you need to pass data from one plugin to another.

Shared variable in Dynamics 365 example | Dynamics CRM Shared Variables Example

In the below video, we have discussed and demonstrated how to use Shared variables in Dynamics 365 Plugins. In which Firstly, we have explained in detail about Dynamics 365 Shared Variables. Secondly, we have processed the step by step process of how and when to use Shared Variables in MS CRM Plugins. And Lastly, I demonstrated the Shared variable in Dynamics 365 example.

What are the Shared variables in Dynamics 365 or CRM?

In Dynamics 365 / CRM Plugins Shared Variables are a way to communicate or pass information between a plugin registered for a Pre-event and a Plugin registered for a post-event.

Using shared variables, we can avoid creating unnecessary calls to the Dynamics 365 organization service as well as the creation of unnecessary fields.

Microsoft Dynamics 365 CRM platform and the execution pipeline provides the ability to pass data from one plug-in to another.

Data is passed from one plug-in to another with the help of IPluginExecutionContext’s property called SharedVariables.

Shared Variables in MS CRM Plugins are a collection of key/value pairs. In other words, developers are able to share data between plug-ins which are registered on both the pre and post events through Shared Variables.

Dynamics 365 provides a framework, in which custom data values can be exchanged between registered plugins in the same execution context with the help of Shared Variables.

Benefits of Using Shared Variables in Dynamics 365 Plugin

  • Pass any Value from Pre-event to Post-Event of the Plugins in Dynamics 365.
  • Certain data validation which needs to be done at post-event can be achieved by passing the value from Pre-event of the Plug-in
  • Avoid storing the values in a custom attribute. Instead of storing the values in a custom attribute, you can also store the value in a context variable. Which is then available in the Post-event for use.
  • It is also possible to read/write data into SharedVariables of context.

Limitation of Shared Variables in Dynamics 365 CRM

  • For a plug-in registered in stage 20 or 40 of the plugin execution pipeline, to access the shared variables from a stage 10 registered plug-in that executes on create, update, delete, or by a RetrieveExchangeRateRequest, you must access the ParentContext.SharedVariables collection.
  • For all other cases, IPluginExecutionContext.SharedVariables contains the collection.
  • One cannot share variables between steps using different messages and/or entities, even if one triggers the other.

Also, find More on Dynamix Academy :

Let’s Connect:

The post Dynamics 365 CRM Plugin Shared Variables – Explained with Example appeared first on Dynamix Academy.

Comments

*This post is locked for comments