Marwan
Marwan

Reputation: 59

Trigger a plugin on page reload in crm dynamics 365

I have an implemented plugin developed in visual studio (we are not using plugin registration tool crm 2016). I want to trigger this plugin on page reload. To explain this plugin is fully developped, it loads the contact information to a form onload event. The idea is that if the user modifies the contact inforation in the form contact, he should be able to reload the form which will execute the plugin.

How can i do this ?

Thank you!

This is the actual plugin which is executed on creation:

    AddStep(Stages.PreOperation, Messages.Update, Modes.Synchronous, DlcocontractorDefinition.EntityName, nameof(CompleteCoContractorInformation));
        AddStep(Stages.PostOperation, Messages.Update, Modes.Synchronous, DlcocontractorDefinition.EntityName, nameof(AssociateCoContractorAddresses));
        AddStep(Stages.PostOperation, Messages.Update, Modes.Synchronous, DlcocontractorDefinition.EntityName, nameof(AssociateCoContractorNationalities));

Upvotes: 0

Views: 1056

Answers (1)

Alex
Alex

Reputation: 23300

Unbound Actions are meant for this, they are in fact messages which you can register plugin steps against.

Since Actions can be invoked by the WebAPI, you can for example bind a JS to a Ribbon command to invoke them, and in turn trigger the plugin step you registered against it.

The "old school" approach was to create a two-options field, register a plugin on pre-update with only that field as filtering attribute, and make the plugin toggle it. To trigger the plugin, you toggle the field and save.


Since the question was edited and changed radically, I'll add: if you want the plugin to execute on reload, the "old school" approach works just fine: register the plugin on update and onsave toggle the two-options field through javascript.

Upvotes: 5

Related Questions