Xrm.Page.data is null

2019-07-20 23:36发布

问题:

I have added a custom form on the opportunity entity and have some javascript attached to it.

I'm calling the form using window.open and the formId in the url to open the form and is only used to create opportunity entities.

Inside the javascript I'm simply trying to populate some fields but the Xrm.Page.data object is always null.

$(document).ready(function () {
    Xrm.Page.getAttribute("ct_testfield").setValue('test');});

Thanks!
Jon

UPDATE: Apparently $(document).ready() fires before the Xrm.Page.data object is loaded.

I instead used the "form properties" dialog on to set my function to fire "OnLoad".

I'm guessing $.ready is firing when the DOM is ready within the IFrame or whatever it lives in and not all the other resources being loaded.

Hopefully this helps someone else.

I will close this in 7hrs when I'm able :)

回答1:

UPDATE: Apparently $(document).ready() fires before the Xrm.Page.data object is loaded.

I instead used the "form properties" dialog on to set my function to fire "OnLoad".

I'm guessing $.ready is firing when the DOM is ready within the IFrame or whatever it lives in and not all the other resources being loaded.

Hopefully this helps someone else.