July 18, 2011
In these examples, I’m going to demonstrate executing the getServerUrl() method from an entity’s form.
To access the getServerUrl() method, simply use:
Inside of an embedded HTML Web Resource (aka an IFrame)
Now since we’re talking context, you can always reference the “ClientGlobalContext.js.aspx” and use:
But I’m wanting more than what’s inside Xrm.Page.context; I want everything inside the “Xrm” variable. For this we can use:
To use the “window.parent.Xrm”, you will need to make sure Cross-Scripting is enabled.
Inside of Developer Tools (F12)
I’ve seen people use crmForm.all and then use the CRM 4 to CRM 2011 conversion utility to code. Instead, it’s much easier to use:
If you aren’t familiar with Execution Context, I would recommend delving a little deeper. My intentions for this was merely to demonstrate how to use the “Xrm” variable in the different scenarios. So whether you are using the Console inside Developer Tools or whatever, you can see using the “Xrm” variable is easy once you have the right execution context.