CRM 2013 New Features: Actions

Ok, so this feature took me a little while to get my head around.  I felt there was a fair gap between the conceptual description of the feature from Microsoft and the reality of how and when you would use it.   Hopefully this post speeds up the learning process for others.

Here’s when you would you use this new feature.  Imagine you want to execute some custom business logic in real time when a button is clicked or an OnLoad, OnChange or OnSave event occurs.  With CRM 2011 you would typically write some JavaScript and develop the business logic in code.  You might query values on the form, you might even hit the CRM APIs to query other data and then you might update values on the CRM form or hit the CRM APIs to create/update other CRM records or pop a URL.     The new Action feature allows us to relocate that business logic into a configurable rule (similar to a workflow rule) and provides a framework for executing that rule from JavaScript.  This means we code the invocation once and then we are done.  The business logic can then be messed around with through a simple GUI.

The common scenario for this I think will be for Approval processes.   Imagine we want an Approve button added to the CRM form and when that button is clicked we want stuff to happen. 

Here’s the steps (in completely the wrong order):

Firstly, add the button to the form.  In CRM 2013 we now have a Command Bar that replaces the Ribbon on most forms.  It is still customized the same way though.  Best bet at this point in time is to use the Ribbon Workbench utility, a CRM 2013 version was recently released.   The button will execute a JavaScript function.

Secondly, write your JavaScript function that will execute the Action.  This will need to be a SOAP call.  Sadly Microsoft have not provided a nice function for this yet.  Actions are defined with input and output arguments so when invoking the Action you can pass values in and then perform additional steps with the values it returns.  I’ve seen these steps documented in a nice lab internally, I assume this info will be publically availably in the SDK or on blog some where.  Let me know if you see a good walkthrough and I’ll reference it here.

Thirdly, configure your Action.   Here, you use the same GUI that you have used in the past for Workflows and Dialogs:

image

You define your Input and Output arguments:

image

And then you write your business logic using the normal Conditions and Actions you will be used to from your Workflow configuration days:

image

You can do some Check Conditions to perform different actions based on the input arguments:

image

You can create, update and assign records and send emails, etc.   And you can assign values to those Output arguments:

image

Your button will fire the JavaScript function which will invoke this Action.  The Action will process the inputs, perform whatever actions you have asked it do, then it will return the outputs to the java script function.  The java script will do whatever you want it to do with those outputs (update the form, construct and then pop a URL, alert the user).

Going back to the Approval scenario I could see the following working nicely:

  1. – The user changes an Approval field to Approved
  2. – A JavaScript function is invoked, it calls the Approval Action passing in the Opportunity Type and Opportunity Value
  3. – The Approval Action runs those Input arguments through a series of Conditions assigning values to an Approver field and a Approval Due Date field
  4. – The JavaScript function receives those Output arguments and uses them to populate corresponding fields on the form and to pop an alert to the user to inform them of the Approver that had been assigned
  5. – The user has immediate visibility of who has been assigned as Approver and is happy

I hope this helps others understand Actions a little better.  I do wonder what they have to offer over a real time workflow.  I think the choice between the 2 will take some careful consideration.  More learning required 🙂

Advertisements

3 thoughts on “CRM 2013 New Features: Actions

  1. Bruce Windram

    It looks like it is possible to create a “coded Action”. It will be great to be able to call some C# directly from a button instead of having Javascript do something that triggers an event for a workflow.

    Reply
  2. Steeve Gauvreau

    Do you tried to develop a javascript function for calling an action. I tried this approach http://a33ik.blogspot.ca/2013/10/custom-actions-walkthrough-for-net-and.html?utm_source=a33ik&utm_medium=twitter

    But I always got an exception for deserialization of the soap message. I’m still confuse if it is design for what you wrote on your post. I think It could be call by an external application for interfacing with CRM, but directly from JavaScript, it quite hard to make it works.

    Reply

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s