[英]MS Dynamics 365 - Iframe - Access Xrm - permission denied
I have problem with integration between MS Dynamics CRM and my javascript app. 我在MS Dynamics CRM和我的javascript应用程序之间集成时遇到问题。
I need to setup communication between Opportunity page and my app in the iFrame. 我需要在iFrame中设置“机会”页面和我的应用之间的通信。
Problem is that when I need to access XRM object in the page, I alway get Access Denied
Error 问题是,当我需要访问页面中的XRM对象时,总是出现“ Access Denied
错误
I tried: 我试过了:
parent.window.Xrm.Page.data.entity.attributes.get(“stateCode”).getValue();
When I call this function from IE Dev tool then it works fine. 当我从IE Dev工具调用此函数时,它可以正常工作。 But from my JS app it throws Access Denied. 但是从我的JS应用程序中,它抛出“访问被拒绝”。
I read a lot about the iFrame integration but none works with MS Dynamics 365. 我阅读了很多有关iFrame集成的信息,但都不适用于MS Dynamics 365。
The problem with "Access Denied" may be related with CORS policy if your JavaScript app is hosted outside Dynamics environment. 如果您的JavaScript应用程序托管在Dynamics环境之外,则“访问被拒绝”问题可能与CORS策略有关。 To avoid this problem on one of my projects we were using postMessage API ( https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage ) instead of direct access to DOM model to send/receive messages between CRM form and IFRAME site. 为了避免在我的一个项目中出现此问题,我们使用了PostMessage API( https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage ),而不是直接访问DOM模型进行发送/接收CRM表单和IFRAME网站之间的消息。
I've written blog article describing how to make it work (unfortunately it is in Polish, but maybe some automatic translation will help;)): http://xrmlabs.piotrgaszewski.pl/?p=455 我已经写了一篇博客文章,描述了如何使其工作(不幸的是,它是波兰语,但也许有些自动翻译会有所帮助;)): http : //xrmlabs.piotrgaszewski.pl/?p=455
The parent.window
of the HTML web resource that is loaded in an IFrame on a CRM form is actually not the form's window. 在CRM表单的IFrame中加载的HTML Web资源的parent.window
实际上不是表单的窗口。 In fact, in Turbo Forms mode it is not possible to access the form's window using the DOM. 实际上,在Turbo表单模式下,无法使用DOM访问表单的窗口。
There are a few other options: 还有其他一些选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.