Wednesday, July 29, 2015

Refresh or Reload CRM IFRAME / Pass data to CRM IFRAME from CRM form – CRM 2015 / CRM 2013


Refresh or Reload CRM IFRAME / Pass data to CRM IFRAME from CRM form – CRM 2015 / CRM 2013

 
// For Posting / Passing data to IFrame, you can call following line on CRM form event. Following line will send/ post data to iframe and you can access data in receiveMessage event on html page in iframe.
 
Xrm.Page.ui.controls.get('WebResource_Dropdown').getObject().contentWindow.postMessage('refresh/data', "*")

 
Html Web Resource
<html>
<head>
    <title></title>
    <script type="text/javascript" src="sa_jQuery"></script>
    <script type="text/javascript" src="sa_JSON"></script>
    <script type="text/javascript" src="sa_XrmServiceToolkit.js"></script>
    <script src="ClientGlobalContext.js.aspx"></script>
    <script type="text/javascript">
        function receiveMessage(e) {
            // You can fetch data that you have posed in "e"
            //Refresh/ Reload data here

            LoadData();
        }

        window.attachEvent("onmessage", receiveMessage);

        function LoadData() {

        }

    </script>
    <meta charset="utf-8">
    <meta>
 </head>

<body onload="LoadData()">
</body>
</html>

No comments: