web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

USD – Return results from a RunXrmCommand

Neil Parkhurst Profile Picture Neil Parkhurst 10,727 User Group Leader

In Unified Service Desk (USD) for Microsoft Dynamics CRM it is possible to use RunXrmCommand to run commands in the context of the currently loaded form.

This is great but what if you wanted to “grab” the results into to then use them in future actions. One advantage being that you would be looking at the value the user has just entered, as the CRM record might not be saved this could differ from what is already in the context or actually saved on the CRM record.

Here is how this can be achieved….

In my example I am going to “grab” the currently entered mobile phone number for a contact. First of all, create an action call that runs a “RunXrmCommand”. The simple code I inserted into the data portion is shown below.

function RunXrmCommand_Example() {
  var currentMobile = Xrm.Page.getAttribute("mobilephone").getValue();
  return currentMobile;
}
RunXrmCommand_Example();

The “important” line of code is “return currentMobile;”, this is going to give me a return parameter containing the current mobile phone number. Notice below that I had changed the phone number but hadn’t saved it. I then ran my action to see what results I got.

Below you can see that I have run this example action in the debugger. Obviously you’d need to call  action(s) from appropriate events in your application, I’m just running it like this to explain how it operates.

Having successfully run the action, I then looked at the Data Parameters. (Not forgetting to refresh them!) Below you can see highlighted a return parameter containing the current mobile number for the contact.

Notice how the parameter has been named, it is the name of the action that returned the value. So to access this value I would use a replacement parameter such as “[[$Return.Contact – Current Mobile]]”

To illustrate how this value can now be used in other actions I have shown a display message action below. Again just as an example, you’d have hopefully have an action that does something much more interesting!

Hopefully you will have found this post useful and will see how to adapt this concept to benefit you USD application. J


Filed under: USD - Configuration Tagged: Microsoft Dynamics CRM, Unified Service Desk, USD

Comments

*This post is locked for comments