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.
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.
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