Xrm.Page
has been deprecated (Deprecated methods are here)
You now have to do the following:
- When you register your event you must tick the
Pass Execution Context as first parameter
checkbox
- In your function you have to add a new parameter called
executionContext
(the name doesn't really matter)
When you've done the above, you can access the new formContext
object which contains most of the methods included in Xrm.Page
More information on formContext
here
For example:
function myHandler(executionContext)
{
var formContext = executionContext.getFormContext();
var myWebResource = formContext.getControl("webResource1");
}
Edit to address null getObject
error
The object returned from getControl()
does have a getObject
method (MSDN) which states it will return either:
- An IFRAME returns the IFrame element from the Document Object Model (DOM).
- A Silverlight web resource will return the Object element from the DOM that represents the embedded Silverlight plug-in.
If you're getting a null object then you've probably got an error with the name of your webresource.
Open your CRM form in designer mode and and locate your webresource. Double-click to view its properties. You're looking for the field name
which in CRM Online is prefixed with "WebResource_"
For example:
