Plugins in Dynamics 365 : Part 1
Hello Guys,
In my previous blogs i have shown how you can perform CRUD operation on any entity in CRM using canvas application. Today we are going learn how we can implement Plugins and what plugin is. 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.
A Plugin is a custom code or a business logic which is integrated with Microsoft Dynamics CRM to extend the standard behavior of the platform. In other words you can say they are Handlers for handling events like creation of new record, updating an existing record, deleting a record or assigning a record.
Plugins are server side script which are written either in C# or in VB language and can run in both synchronous and asynchronous mode. Consider a scenario where you have to create a registration form for registering a new customer for your business. Now while creating a registration form we need to keep some points in our mind and those are:
- Customer should fill correct data.
- Customer should be identical and can not be duplicated.
- Customer record should contain customer reference number when customer record is created.
- Customer should get notification about his registration via mail or call or text message.
To justify first point we can use either JavaScript or Business Rule. We can validate customer data on client side on form before it is getting submitted.
Now suppose we want to identify customer is duplicated or not and to get this thing done we need to search for existing data which is nothing but the server side process. However you can retrieve data at client side also using JavaScript but writing a server side query on client side is not a good practice and therefore we can use plugins.
Also we want once customer data is submitted on server for creating a record, we want to notify the customer for his/her registration successful. To notify a customer we can have email, phone call or sending message which is different activity or process. We can use plugin for achieving these all process. We can set attributes value before creation of the record. For example Customer Reference Number.
Apart from this we can call external web services on certain events such as saving or updating a record.
To create a plugin we will use visual studio 2017. you can use any IDE installed in your computer. Below are the steps:
Step 1:- Start Visual Studio.
Step 2:- File -> New -> Project -> Class Library(.Net Framework) ->Specify the name -> "DynamicsPlugin" -> Ok.
You should build any custom client applications using Microsoft.Net Framework 4.6.2 or later starting with the Dynamics 365(Online) v9.0 or later version only applications using Transport Level Security(TLS) 1.2. Better security will be allowed to connect TLS1.2 is not the default protocol used by .Net Framework 4.5.2, but it is in 4.6.2.
Step 3:- Right click on the project -> Manage NuGet Package Manager -> Search Microsoft.CrmSdk.CoreAssemblies. -> Install it.
Step 4:- Sign your project by right clicking on the project in the solution. Choose properties, then select Signing -> Create a new key.
Key File Name :- "DynamicsPlugin".
Step 5:- Save and Build the project. Make sure no errors and warnings are available.
So these are the steps for creating a new plugin for your project. In our upcoming blogs we will implement validation using plugin.
Hope it helps...
👍
ReplyDeleteThanks.
DeleteThanks you very much
ReplyDeleteRequesting to write a simple plugin and show execution steps in crm
@krishna Thanks for your comment. In our upcoming blog i'm going to cover rest topics.
Delete👍
ReplyDeleteThanks.
DeleteNice and Informative👌
ReplyDeleteThanks
Delete