Actions in CRM 2013

One of the most powerful features introduced in CRM 2013 is Actions. It strongly supports the concept of XRM platform. Actions are the Custom messages which can be created for any entity or globally to perform business operations like create/update/Assign etc. (more than what a Workflow can do). Looking first time we get a feeling that it is very similar to Workflow but hold on it’s very different from WF’s or Plugins.

Below are the key points which make it different:
  1. Can be associated with single entity or globally.
  2. Actions support Arguments – Input and Output Arguments.
  3. Can be only called through web service calls – either JavaScript/Plugins/Web through API calls.
  4. Supports Rollback and executes in real time.
  5. Always runs under the context of the calling user.


Arguments are the parameters or the variables which can be used while creating the action. There are two kinds of arguments

 Input Arguments:

These are the parameters which need to be passed during action call. These can be Optional/Mandatory. For Mandatory argument it is necessary to provide some value while calling this action. These input arguments can be used as variables while performing any operation in the action.

Output Arguments:

These are the parameters which can be returned when the action is called. These can be Optional/Mandatory.

To understand in an easy way we can compare actions with a Function/method in normal C# programming which can have parameters and also can return something at the end.

Let’s take a look of the different types of Arguments it supports.



Let me create a simple Action on Enquiry entity which has one Input Argument: ProjectName [string]

To create this we need to navigate to Processes and select Category as Actions. In primary entity I am selecting Enquiry which is custom entity in my case. I have taken one Input Parameter- ProjectName. And in the step I am using this Variable during creating a Project’s record which is again a custom entity.


And here is the snap of the Step which I have configured. Here we can see that I am using this ProjectName as a dynamic value during the Project Creation. Here note that new_EnquiryCreateProject is the name of the Action which should be referred while calling this through API.


Let’s activate this Action and see how we can call this from Plugin or JavaScript.

Calling Actions from Plugins

Now we can call this Action from our Plugin. I have a Plugin which fires on Post Create of Enquiry. There I am calling this Action. I am passing the Input Argument ProjectName as Parameter before calling this Action. Once this is called It creates a new Project record.

// Calling the Action - new_EnquiryCreateProject
OrganizationRequest req = new OrganizationRequest("new_EnquiryCreateProject");
req["ProjectName"] = "This is a test operation for using Actions in CRM 2013 ";
req["Target"] = new EntityReference("new_enquiry", enquiryObj.Id);

//execute the request
OrganizationResponse response = service.Execute(req);

Calling Actions from Javascript

Yes we can call Actions through JavaScript. I have a stage field in the Enquiry entity and on Change of Stage field I want to call this Action. Let us see below how we can use this.

 function CallActionFromJavaScript() {
    var projectName = "Project Created through Action from Javascript";
    var entityId =;
    var entityName = "new_enquiry";
    var requestName = "new_EnquiryCreateProject";
    ExecuteActionCreateProject(projectName, entityId, entityName, requestName);}
function ExecuteActionCreateProject(projectName, entityId, entityName, requestName) {
    // Creating the request XML for calling the Action
    var requestXML = ""
    requestXML += "<s:Envelope xmlns:s=\"\">";
    requestXML += "  <s:Body>";
    requestXML += "    <Execute xmlns=\"\" xmlns:i=\"\">";
    requestXML += "      <request xmlns:a=\"\">";
    requestXML += "        <a:Parameters xmlns:b=\"\">";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>Target</b:key>";
    requestXML += "            <b:value i:type=\"a:EntityReference\">";
    requestXML += "              <a:Id>" + entityId + "</a:Id>";
    requestXML += "              <a:LogicalName>" + entityName + "</a:LogicalName>";
    requestXML += "              <a:Name i:nil=\"true\" />";
    requestXML += "            </b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>ProjectName</b:key>";
    requestXML += "            <b:value i:type=\"c:string\" xmlns:c=\"\">" + project
Name + "</b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "        </a:Parameters>";
    requestXML += "        <a:RequestId i:nil=\"true\" />";
    requestXML += "        <a:RequestName>" + requestName + "</a:RequestName>";
    requestXML += "      </request>";
    requestXML += "    </Execute>";
    requestXML += "  </s:Body>";
    requestXML += "</s:Envelope>";
    var req = new XMLHttpRequest();"POST", GetClientUrl(), false)
    req.setRequestHeader("Accept", "application/xml, text/xml, */*");
    req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    req.setRequestHeader("SOAPAction", "
    //Get the Resonse from the CRM Execute method
    //var response = req.responseXML.xml;
function GetClientUrl() {
    if (typeof Xrm.Page.context == "object") {
        clientUrl = Xrm.Page.context.getClientUrl();
    var ServicePath = "/XRMServices/2011/Organization.svc/web";
    return clientUrl + ServicePath;

And now the most Amazing part of Actions are that we can consider this as a unique message and can register this through Plugin registration tool and can do Custom Validations if we want to do during the execution time.

Let’s say during the execution of this Action I want to validate something or abort this Operation in certain conditions then we can easily do by registering this as a message which is  a great example of Xrm support in CRM 2013 as now it is not restricted to messages like Create, update, delete etc.

Below it is shown how we can register this through Plugin Registration Tool.


Note: These actions are little bit different from Plugins as return type of the Target is not Entity but it is Entity Reference. During the execution of this Action we can get the Input Arguments and use this for any type of validations.

Below is the sample where I am reading the values of the Target and the Input Argument ProjectName used in the above example.


Here we can clearly see that the context contains only 2 values one is the Parameter and the other one is the Target.

As a developer, introduction to Actions in this CRM 2013 release is really a great improvement from CRM’s perspective which will help us to minimize the coding part and also achieve some complex requirement easily.

Happy Reading!!!!!


, , , , , , , , , ,

  1. #1 by Larry on January 5, 2014 - 4:32 am

    thank you for your post. This was the most helpful post on actions I could find.

  2. #2 by céline on March 4, 2014 - 10:22 am

    Very good post, but how to pass a parameter of type ‘entity’ in action with javascript?

  3. #3 by Manu on April 9, 2014 - 1:04 pm

    While searching for CRM Actions new feature,i came across this blog and it was helpful.You metioned about calling Actions from-Plugins and Javascript.Can you please elaborate on where to write the code for Plugins?Did u use CrmSvcUtil to generate a class and call that class in the Solution?Can anybody please help me with the C# part where to write the Plugin(Step-by-step) ?


  4. #4 by Preethi on April 10, 2014 - 11:59 am


    I’ve created an Action, tried to trigger it from JS using SOAP call. Its not getting triggered.
    I’ve called it from custom code, its works fine. With SOAP call, the request gets succeeded with response statuscode =200 , but no impact on Action. Could you pls help out?

  5. #5 by ravideep on April 22, 2014 - 11:25 am

    Hi Deepak,

    How to create custom message for action?
    How to call global action from javascript?

  6. #6 by Rajesh on May 6, 2014 - 5:59 am

    Hi Deepak,

    I am trying to invoke the custom action from Javascript and it’s not working. The request goes through fine but the responseXML.xml is empty and the responseXML has no child nodes.

    Can you pls assist ?

  7. #7 by roxanna on March 20, 2015 - 5:17 pm

    Very informative.
    Also, FYI – I came across your post from this link. I thought it would be nice to let you know that your work has gotten recognition. Thanks.

  8. #8 by Loz on April 15, 2016 - 1:36 pm

    Thanks for this Deepak, yours was the only blog post that mentioned this: “Target is not Entity but it is Entity Reference”. Not knowing this was causing me all sorts of headaches and I couldn’t figure out why my plugin wasn’t firing. Now all sorted!

  9. #9 by siva on January 6, 2017 - 5:55 am

    what is the code difference between asynchrous and synchronous calling of action

  10. #10 by Nelson Giraldo on December 4, 2017 - 1:58 pm

    Excellent, thanks for the info, very helpful.

  1. jadanaren

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: