Execute Global Action in Dynamics 365 v9.0 Using“Xrm.Utility.invokeProcessAction”

By | August 23, 2018

Introduction:

In Dynamic 365 v9.0 we can use Xrm.Utility.invokeProcessAction to execute Global Action. When we need to create an Action to be executed on multiple entities, we can use Global Action in Dynamics 365.

Here in the below example, we are cloning Account record by executing Global Action in Dynamic 365 v9.0.

Create Global Action:

1. Go to Setting -> Processes -> Click New and then select Category as “Action” and Entity as “None(Global)” as you can see in the below screenshot.

1Execute Global Action in Dynamics 365

2. We have selected Entity: None(Global) for executing the global action. So by doing this, we can reuse the same Action globally to any entity where ever needed.

Execute Global Action in Dynamics 365

3. It accepts an input and Output parameter. You can specify parameters of any of the following data types.

Execute Global Action in Dynamics 365

In our case we are passing AccountId as an input parameter and ClonedId as an output parameter, so when global Action will execute it will take AccountId as an input parameter (Account record Guid as a string Parameter) and in result will return ClonedId as an output parameter(Cloned Account Guid as a string parameter).

Execute Global Action using Xrm.Utility.invokeProcessAction:

Execute Global Action in Dynamics 365

Here as you can see in the below screenshot, in console we got Cloned Account record Id as output paramater

Execute Global Action in Dynamics 365

Conclusion:

By using the above simple steps one can use global Action on multiple entities in Dynamics 365 CRM.

Read More about invokeProcessAction (Client API reference).

Copy System and Custom Entities in Dynamics CRM

2 thoughts on “Execute Global Action in Dynamics 365 v9.0 Using“Xrm.Utility.invokeProcessAction”

  1. Mudassar

    I tried to use the invokeProcessAction but getting error code: 2147746581″This action is not supported”

    1. inogic

      Hi,

      We have checked with the request and found that it stops working on Unified Client Interface. So instead of using “Xrm.Utility.invokeProcessAction” request, you can use “Xrm.WebApi.online.execute” request to execute Action. Here in the below code, we have an input parameter named AccountId and our Action name is new_CloneAccount.

      //Execute Action
      function executeAction(executionContext)
      {

      var functionName = “executeAction”;
      var parameter = null;
      var formContext = null;

      try {

      //Get form Context from Execution Context
      formContext = executionContext.getFormContext();

      //parameter
      var parameter = {

      AccountId: formContext.data.entity.getId().replace(“{“,””).replace(“}”,””), //passed Form Context instead of Xrm.Page as it going to be deprecated.

      //Metadata
      getMetadata: function () {
      return {
      boundParameter: null,
      parameterTypes: {
      “AccountId”: {
      “typeName”: “Edm.String”, //Input Parameter type, we have string type of parameter, so passed Edm.string
      “structuralProperty”: 1 //Primitive type
      }
      },
      operationType: 0,
      operationName: “new_CloneAccount” // Action name
      };
      }
      };

      //execute Action
      Xrm.WebApi.online.execute(parameter)
      .then(
      function (data) {
      alert(“Success”);

      },
      function (error) {

      var message = error.message;
      }
      );

      } catch (e) {
      alert(e.message);
      }
      }

      FYI, you can refer our Blog on “Xrm.WebApi.online.execute” request, please refer below link:

      https://www.inogic.com/blog/2019/01/execute-action-using-xrm-webapi-online-execute-in-dynamics-365-crm-v9-0/

      Hope this helps.

      Thanks!

Comments are closed.