Skip to main content

Execute/Access CRM actions from Iframe using Javascript- Dynamics CRM 2016 / 365 (Turbo Forms)

Execute/Access CRM actions from Iframe using Javascript- Dynamics CRM 2016 / 365 (Turbo Forms)

Some times we need to perform CRM Page actions from Iframe , for that purpose use below code snippet .


Code to be written on Iframe Page

window.parent.postMessage("Submitted", "*");

Code to be written on CRM Form Javascript


if (window.XMLHttpRequest)
    window.parent.addEventListener(
"message", receivePostMessage, false);else
    window.parent.attachEvent(
'onmessage', receivePostMessage);


function receivePostMessage(e) {    
    
if (e.data == "Submitted") {
        // CRM Actions  , here I am closing the form as an example.

        Xrm.Page.ui.close();
    }




Comments

Popular posts from this blog

How to Integrate WhatsApp with Dynamics 365 Omnichannel – On Trial

How to Integrate WhatsApp with Dynamics 365 Omni Channel – On Trial Pre Requisites a.        Trail Environment with Customer Service Enabled, Preferably Netherlands as Location Ref : https://docs.microsoft.com/en-us/dynamics365/omnichannel/try-channels b.        Twilio Trial Account Ref : https://www.twilio.com/docs/usage/tutorials/how-to-use-your-free-trial-account#sign-up-for-your-free-twilio-trial Let’s Start the Configuration! Configuration: Dynamics 365 Channel Integration Framework - V2 1.        Go to dynamic 365 administration center via below link after logging to trial account https://port.crm4.dynamics.com/G/Applications/Index.aspx 2.        Make Sure Channel Integration Framework in Enabled, like in below screen shot else, configure it . By default, this should have enabled. Configuration: Omnichannel for Custo...

Delete record using JQuery and OData in Dynamics CRM 2011

function DeleteRecord(id, oDataSetName) {     var serverUrl = Xrm.Page.context.getServerUrl();     var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";     $.ajax({         type: "POST",         contentType: "application/json; charset=utf-8",         datatype: "json",         url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + id + "')",         beforeSend: function (XMLHttpRequest) {             //results will be returned as JSON.              XMLHttpRequest.setRequestHeader("Accept", "application/json");             //HTTP method DELETE               XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");         },         success: function (da...

How to attach refresh event on Dynamic CRM 2011 subgrid using Java Script / JQuery ?

// Attach the function OnFormLoad event function OnFormLoad() {     setTimeout("SubGridRefresh();", 2500 ); } function   SubGridRefresh() {     var subgrid = document.getElementById("subgridid");     if (subgrid.readyState != "complete") {         // recursive till the subgrid is loaded         setTimeout(SubGridRefresh, 1000);         return;     }     // if subgrid fully loaded       if (subgrid) {         // attach the name of the custom function to grid          subgrid .attachEvent("onrefresh", OnRefresh_SubGrid);          subgrid .control.add_onRefresh(OnRefresh_SubGrid);     } } function   OnRefresh_SubGrid() {     //custom code to execute     var entityid = Xrm.Page.data.entity.getId();     alert(entityid); } ...