Plugins in Dynamics 365 : Part 4
Hello Guys,
In my previous blogs i have shown how to validate attributes in Pre-Validation Stage and how to register plugin.Today we will see how to register plugin for update message. But before if you are new to our blog then do follow us to know more about Dynamics and Power Platform. Also if you like our blog then please comment and share this blog with your friends.
In our previous blog we have seen how we can get the Context using service provider parameter of the Execute method.Well while working with Context and Target we need to keep some points in mind and those are:
- Context will be available for every plugin execution.
- It is not necessarily that Target will be available for every plugin execution. It depends on the plugin step configuration. However we can register a plugin for different messages but not all of them will have a Target. Ideally Create,Update and Delete messages are having a Target.
- To identify what will be there in Target, we need to identify the messages. For example Create and Update plugins, we will always have a Target and it is of type Entity where as for Delete plugin we will be having Target but it will of type Entity Reference.
Previously, we have registered our plugin for create message. Today we will register our plugin for update message also.
Step 1:- Open Plugin registration tool and connect your organization which we already did in our previous blog.
Step 2:- Right click on DynamicsPlugin and select register new step. Specify below details and click on register new step.
Now in the above example, firstname,lastname,business phone, email etc. may be modified once for every 100 updates, so 99% of the time the plugin might really be doing nothing.
It would only make sense to have some mechanism that would allow us to tell Dynamics that we only want the plugin to run when above specified attributes are updated. To do so,
Step 3:- Double click on update step.
Step 4:- Browse for filtering Attributes. Select attribute which you want for update check.
Once you select the attributes, click on Ok and Update Step. Check in CRM this is working on update or not.
Note: you can not do the same for create step. Just keep in mind when you register your plugin on the create message, it will run for every create. You can not use filtering attributes here.
Note: If you change any code in your class library then compile the project and update the plugin.
Hope it helps...
👍
ReplyDeleteThanks
DeleteNice blog 👌
ReplyDeleteThanks
Delete