Dynamics 365: Trigger action using JS

Trigger action using JS

In many cases we may encounter a requirement where we are required to perform server side logic utilizing client side events (onchange, onsave, onload…etc) in MS CRM. We generally prefer to use actions for dealing with these kinds of operations.

So in this blog, we’ll take a detailed look at how to trigger an action and retrieve the action output parameters using script with a simple example.


Let us create a simple action which will trigger on save of the account and create a primary contact.

  1. Create a simple global action which has one input and one output parameter as below.


    The steps performed in this action are:

    • Verifying if the target account has primary contact and contains email address.
    • Creating a new contact based on the account details.
    • Updating the primary contact details on target account.
    • Returning the contact reference of the newly created contact as output parameter.
      Just to let you know, contact reference is an auto number field in the contact entity.
  2. On save of the account record, we’re going to trigger this action by using script.
  3. From the action response, we’re taking the ‘Contact Reference’ (output parameter) value and displaying it on the account form as a form notification.



Posted By: Ashok Jinkala, Osmosee

Are you interested? follow us and get notified of new posts

Leave A Reply

four × 2 =