Views:

There are many business scenarios where we are required to call a Plugin using JavaScript. In this blog, we will discuss one of the approaches that is very effective.

To call Plugin using JavaScript, we should:

  • Create an action in CRM
  • Register Plugin
  • Register step on action message
  • Call this action in JavaScript

Business Scenario:

On Order entity we have a custom field, this field on change we trigger a plugin. Create an action, it is blank action with no arguments or steps. Activate that action and use that action name while registering step in plugin.

Write the plugin code and register the plugin. In this scenario, we just have to write throw exception in code.

Register New Step

In step creation, we select message as action name (i.e., mtc_sendemaila49b5f8ca894e811) and we select primary entity as order and event pipeline stage as post-operation. Click on Register New Step.

After completion of plugin registration, call your action in JavaScript code. Below code shows how to call action in JavaScript for your reference.

We call above code (callAction function) during on change event in order entity. The below screenshot shows exception message in plugin.

Still need any help? Write to us at salesteam@mtccrm.com. We will help you.