javascriptdynamics-crmmicrosoft-dynamicsdynamics-365dynamics-crm-365-v9

Dynamics 365 V9 web resource get context


I used this article to open a popup window when clicking on a button in the Lead form. In the onclick event of a button in this popup window, I want to set the value of a field in the parent form. How can I do this in V9, since xrm.page is deprecated? I would like to know the equivalent of

window.parent.Xrm.Page.getAttribute("subject")

The line above has a value of null in the lead form.

EDIT: in the link posted by Arun in the comment down here, it is written that "although Xrm.Page is deprecated, parent.Xrm.Page will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource."

Since I am opening a popup window, that is not embedded in the form, I can't use parent.Xrm.page. So it is not possible to set a value in thet parent form with a script inside a popup window?


Solution

  • You can use window.opener to do it.

    window.opener.Xrm.Page.getAttribute('subject').getValue();