In the post about Unified Service Desk for Microsoft Dynamics CRM I am going to give an example of how to use the ExecuteOnExpressionTrue action.

This example could be done by calling ExecuteOnExpressionTrue from your global manager. The ExecuteOneExpressionTrue action will exist on your global manager out of the box but can be added to any hosted control. So for this demonstration I’m going to create a UII Action on my “Contact” hosted control. Simply to illustrate the point.

So begin by starting to create an action linked to the Contact hosted control. Mine ends up looking like the one below;

When I tried to select ExecuteOnExpressionTrue, the action didn’t exist. So I selected new and simply added a new action. As I have shown below.

Let’s consider the data portion of this action in a little more detail, I have entered, “[[contact.donotphone]+]” == “true”. A fairly straight forward condition.

You will find the documentation on Microsoft’s site gives the following example of a data portion for this action. (Which is worth considering for a second as it hints as some additional capabilities.)

milliseconds=5000
function IsAccountLoaded()
{
return "[[account.Id]$+]" != "";
}
IsAccountLoaded();

milliseconds=5000 would mean wait a maximum of 5 seconds for this action to be true. Useful if your data isn’t available instantly. (Although 5 seconds might be quite a long time for a use to wait!)

You can also see that JavaScript has been used to evaluate the expression. This syntax might be useful if you need to do a more complex comparison or wish to only return a true result if multiple items match your criteria.

But back to the action …… Having saved your action, you then add one or more sub actions that will be triggered if the results are true. In my example I am simply going to display a message warning the operator to not call this contact. The action I created to display the warning looked like this;

My action to display the message was then added to the sub actions on my ExecuteOnExpressionTrue action. Shown below;

All that remained was to trigger the ExecuteOnExpressionTrue action each time a contact was loaded, so I added my action to the BrowserDocumentComplete event on my Contact hosted control. As shown below.

Now when I open a contact who has their contact preference on “phone” set to do not allow, the operator will get a useful popup remaining them not to call the contact. This same message is also triggered when the “do not allow” setting is first applied. However, loading a contact who accepts phone calls gives no such warning message.

Hopefully this simply example has given you an insight into the ExecuteOnExpressionTrue action. J

4 responses to “USD – ExecuteOnExpressionTrue”

  1. Hi Neil,

    The ability to add conditions looks promising. I currently have a button on my contact page,which creates a new case and it fills an account field on the case with the account of the contact. These are the data parameters of the action call connected to the button:

    LogicalName=incident
    xxx_accountid=[[contact.parentcustomerid.Id]]
    xxx_accountidname=[[contact.parentcustomerid.name]]
    customerid=EntityReference(“contact”,[[contact.Id]])
    customeridname=[[contact.fullname]]
    xxx_contactid=[[contact.Id]]
    xxx_contactidname=[[contact.fullname]]

    Unfortunately in case the contact has no account, the action will fail and the new case form will not load, so my goal is to build in a check if the account of the contact is filled or not.

    Would you have a suggestion how to accomplish this? Would this be able with something similar mentioned by you above or would it be possible to simply add some code to the data field?

    Looking forward to your reply!

    Like

    1. First thing I would do is make a small change to the code above that might work. A guess but worth a shot. In the account Id and name fields add a plus to the replacement parameter.

      Xxx_accountid=[[contact.parentcustomerid]+]

      If that doesn’t work try two actions. In the advanced tab add this to the condition on one…
      “[[contact.parentcustomerid.Id]+]”==“”

      If that action don’t include the lines that set accountid and name. Then create another action that has the lines but it has a condition of ….
      “[[contact.parentcustomerid.Id]+]”!=“”

      Add both actions but only one will fire each time. And your problem will be solved.

      Like

  2. The addition of the + seemed to be enough! new cases are now correctly getting created. It’s good to know the second method would be viable as well and will come in handy in a different scenario, but the first solution works fine for this incident.

    Thank you very much!!

    Liked by 1 person

Leave a comment

Trending

Website Powered by WordPress.com.