Wednesday, 20 March 2019

Refresh IFrame in Dynamics 365 UI or UCI

Hi,

We all very used to write the piece of the code from this link whenever we need to refresh the IFrame in CRM.

Very unfortunately, the same code is not working in Dynamics 365 UI version 9.x on wards. No need to worry on that, we have the work around for the same.

We have to pass the WebResource name if it has the full URL and vice versa. Here is the piece of the code for the same. I know, it is little confusion but we have live with it until the PG Team fixes the issue.


                var src = null;
                var newsrc = null;
                var url = Xrm.Utility.getGlobalContext().getClientUrl() + "/WebResources/";
                var iFrameName = "IFramControlName";
                var IFrameControl = formContext.getControl(iFrameName);
                src = IFrameControl.getSrc();
                IFrameControl.setSrc(null);
                if (src.indexOf(url) != 0) {
                    newsrc = url + src;
                }
                else {
                    newsrc = "abc.html";
                }

                IFrameControl.setSrc(newsrc);

Hope this helps.

--
Happy CRM'ing
Gopinath

No comments:

Post a Comment