Recently I found problems with RunXrmCommand in Unified Service Desk (USD) for Microsoft Dynamics CRM 2016, in this post I will describe our problem and the work around that was identified.

We often use RunXrmCommands to inject JavaScript into CRM forms, this can be useful to make use of Xrm.Page commands to interact with the CRM form. But I found that my RunXrmCommand actions started to fail after quick create forms had been displayed.

For example, the following command can be used to identify when the contents of a CRM page contains unsaved changes. Below you can see how I have used this in an action on my phonecall hosted control.

var a = Xrm.Page.data.entity.getIsDirty();

Following the user opening a quick create form the commands started to fail. For example, if they created a new contact directly in the “from” field on the phonecall everything from then onwards would stop working.

Capture

The revision below solved the problem;

var x = top.document.getElementById("contentIFrame0").contentWindow.Xrm;
var a= x.Page.data.entity.getIsDirty();

My action then looked like this;

If you are having problems with the RunXrmCommand hopefully this quick workaround will be helpful. (If not elegant code!) J

2 responses to “USD – RunXrmCommand and Quick Create Forms”

  1. […] via USD – RunXrmCommand and Quick Create Forms — Microsoft Dynamics CRM and Unified Service Desk […]

    Like

Leave a comment

Trending

Website Powered by WordPress.com.