Posts

Showing posts from January, 2022

how to get the XRM/FromContext on html page in D365.

Let’s image that you created a simple HTML web resource that needs to do some work and then pass it back to the form. Previously to do so you would use parent.Xrm. However, the problem is that previous parent.Xrm and Xrm.Page is deprecated. But know you have supported way to do so - welcome getContentWindow. syntax:  formContext.getControl(arg).getContentWindow().then(successCallback, errorCallback); 1. Create a java script webresource in Solution with below code. 2. Add the Event onLoad / OnChange on Entity Form and Pass Parameter. function Form_OnchangeOROnLoad(executionContext) {     var formContext = executionContext.getFormContext();     var wrControl = formContext.getControl("new_WebResourceName.htm");     if (wrControl) {         wrControl.getContentWindow().then(             function (contentWindow) {                 contentWindow.setClientApiContext(Xrm, formContext);             }         )     } } 3. Create Html WebResource in Solution wit below Code. 4. Add Html f