A Plug-in is a custom business logic code which is used to execute an action when a particular event takes place. It acts as event handlers in CRM and is triggered in events like create, update, delete, etc. Plug-ins are used to automate processes like sending emails to customers when some events take place in CRM.
Shared Variables in Plug-in:
Shared Variables in Plug-in was introduced in CRM 4.0. Shared variables are used for passing data between plug-ins registered on both pre and post events. So, instead of storing values in custom attributes, they can be stored in context variable. Read and write data into shared variables of context.
Real-time Shared Variables Business Scenario:
In the invoice entity, we wanted to change the exchange rate field but couldn’t do it because we were unable to change the value of base currency. So, we decided to use shared variables to change the exchange rate field of the invoice entity. Let’s see how it’s done.
Add a data into shared variable context in plug-in.
And the below code shows shared variable data used in another plug-in.
After completing plug-in registration in CRM, register a new step, i.e., select update event and primary entity as invoice and select pre-operation.
Register a new step into another plug-in, i.e., select retrieve exchange rate event &primary entity as transaction currency and select post-operation.
Do you have any requirement for CRM Plug-ins? Get help from experts. Contact email@example.com now!