In a custom entity, I have a Form from which I can call a web resource(HTML) that shows information retrieved from other entities to the user. If the user clicks on a specific button in the HTML, a field in the calling form must be changed. If you try to update a field from the web resource same as we do it in the form scripts(Using XRM Framework), this is not possible as the scope of the XRM Framework is directly related to the script in the form. So, to update any field in the form from a web resource, we should use the following code:
// Adding window.opener to our normal Xrm.Page object model // to use Xrm it in the web resource(HTML) window.opener.Xrm.Page.data.entity.attributes.get("FIELD_NAME").setValue(value);
By using window.opener, we’ll be able to use XRM object model same as we do it in the Form Scripts.