I am trying to access the Xrm.Page.data object from the HTML web resource that I inserted into the form in CRM 2011. However, depending on how I try to access the Xrm object, I found that it is undefined or that Xrm.Page.data is null. The code for the web resource is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript"> function OpenMyApp(e){ alert('Xrm defined: ' + (typeof Xrm != 'undefined')); </script> </head> <body> <a onClick="OpenMyApp(event);" href="#">My Link</a> </body> </html>
I successfully got Xrm.Page.data from a JavaScript function that is part of a library that fires a form event (e.g. Form.Load). It is simple when it is embedded in the HTML web resource in the form that I am facing this problem. Can someone explain what I'm doing wrong, and if there is a way to access Xrm.Page.data in this way, what would I like to do?
Thanks.
source share