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

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Friyank’s blog / {Back to Basic} Register a ...

{Back to Basic} Register a Plugin

Friyank Profile Picture Friyank 944

Create a Plugin explains how plugin is created, But next step is to register a plugin.

first thing to understand is
You have a plugin Dll created in visual studio, this Dll is in your local drive.

Your CRM Online is on Azure server, So now How to Link both?

Lets say you want to call this plugin on create of any entity (custom or system) for instance, this plugin should trigger when contact is created in CRM.

So how CRM will know that my plugin which is in local drive has to execute on contact creation.

Through the bridge, This Bridge is called Plugin Registration tool.

To download this tool, go to Nuget package manager and run the following Nuget command.

Install-Package Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -Version 9.0.2.7

To find where this Plugin tool is downloaded, Go to File Explorer where this project is created, and Find a folder called “Packages”,

packages\Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.9.0.2.7\tools\PluginRegistration.exe

Locate to above path and run this Exe.

Once plugin tool starts,
Click Create New Connection
Select Display list of available organization – This will allow you to select instance from all the instance you have access to.
Online Region – Select Don’t Know – as it will checks all the server worldwide to find instances associated to your account.
Add User Id and Password which you created while starting a trial > Click Login.

Once login is done, you will see many assemblies are already there in this tool which is registered,
This Assemblies are created and registered by Microsoft for internal process.

To start Registration, you must have Class library Dll created, To know how check this
Once you have Dll in your Bin folder and here your CRM is connected to Plugin Registration tool, then you go to Plugin tool and click Register and Select Register New Assembly.

This will open up Register New Assembly wizard.
Here ,
Step 1 Select your Assembly
Step 2 : This displays list of class in this assembly which has inherited IPlugin interface.
You can select all or selected Class,
In my scenario, i have only one class which i will select.
Step 3 : Isolation Mode – This is about How your plugin will run, in Sandbox, which is isolated from your CRM instance or none, which is the case of on-premise.
For D365 Online, you cannot register plugin in None Isolation mode, Plugin is always register in Sandbox server which is isolated from CRM.
Step 4 : This is location in your sandbox environment, like in some Database or GAC or on to disk.
Step 5 : This is log which display status of registration.

Click Register Selected plugin, this will prompt with success of how many plugin and assemblies is registered.

Now, we register the plugin, How CRM will know that this plugin should be triggered when a contact is created and not always.

Do we have to do anything in CRM for this or you else how ?
The answer is Registering the New step beneath this Assembly.

Expand the Assembly we just registered, Right on Plugin which is inside it. and Select Register New step.
Step Wizard is what we have to know.
Message – This is a the actions or task or in common words events which takes places in CRM, like Create, update delete, associate, retrieve, close etc.
There 100’s of messages but we want to trigger this plugin when create action or event is fired in CRM.
Primary entity – Now we have selected create action or message but we have to specify on which entity creation, so we provide contact here.
Secondary Entity – Most asked interview Question – What is secondary entity –
You have requirement to link some related record or remove related record, in this case you have to provide two entity, this is where secondary entity tick in.
SetRelated or RemoveRelated is the message which take advantage of Secondary entity, as you are associating another entity record with current record and you want your plugin to be trigger at time of association.
In our case, creation has no option or requirement to select secondary entity.
Filtering attribute – This is used mainly when its an update message, because, create is a single task but update itself include updating of attributes so calling plugin on each attribute will hamper your CRM performance and so you filter the attribute on which all attribute this plugin should get triggered.
Event Handler – This is your plugin for which you are creating this step.
Step Name – Give some meaning full name as per your understanding.
Running in user’s context – Specify on whose behalf this plugin should trigger. default is calling user, but you may have users who dont have access to entities which will are used inside the plugin, so in that case you can do impersonation.
Execution Order – When you set of Sequence plugin and you want to decide which will run first and which thereafter.
Pipeline stage
PreValidation – a stage where plugin will run outside the Database transaction, DB transaction is key feature of any database, what transaction do is, if you have series of actions to be performed within one plugin, and any one fails it should not be treated as half completed and half pending so. it roll back to initial stage when plugin was started.
but Pre Validation is outside of such DB transaction and it helps to check and validate the data. mostly no plugin has any task or action logic in this stage as it dont allow rollback.
PreOperation – This is when the record is not saved and you want some task to be performed like, move same data to other System and if it success there then only add here else return or such.
PostOperation – This is when the Record is created or when the task is performed, at this stage you message action is performed.
Some have requirement to perform some task only after record is created like, creating child records or such, you cannot created child record, unless parent record is created.
{Will discuss more about this in future blogs }
Execution Mode Synchronous – It will run at the same time, keeping user wait.
Asynchronous – This is background plugin, ofcourse you cannot have async plugin on prevalidation or preoperation.
Deployment – Server/Offline – its name explains well.
You can even choose to delete async plugin operation if its succeed.

Click Register New step. this will register your plugin on contact creation

Create a contact you will see plugin getting triggered. write some logic in your plugin like updating CRM record or anything.

Comments

*This post is locked for comments