USD – RunXrmCommand and Quick Create Forms

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 thoughts on “USD – RunXrmCommand and Quick Create Forms

  1. Pingback: USD – RunXrmCommand and Quick Create Forms — Microsoft Dynamics CRM and Unified Service Desk | HIMBAP

  2. Pingback: USD – The Book | Microsoft Dynamics CRM and Unified Service Desk

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 )

Connecting to %s