passing dynamic parameter (field values) to webresource on Dynamics CRM using custom parameter (data)

情到浓时终转凉″ 提交于 2019-12-14 03:56:26

问题


Can't get the values into the querystring of the webresource iframe url. I add the field name (schema name) to the custom parameter (data) and get the field name on the querystring (static) and not the field value.


回答1:


Even though there are posts saying you can pass dynamic values to the custom parameter (data) of the webresource, my experience is the same as Adi's above, that those parameter are only for static values.

In that case the easiest alternative I found to get the values of the form fields into the webresource are even simpler than what I was trying to do. By just adding: window.parent. you get access to Xrm.Page. So all you have to do is:

var formfieldValue = window.parent.Xrm.Page.getAttribute("CRMFieldSchemaName").getValue();

Don't forget to place it within a javascript tag on the webresource:

<script type="text/javascript">
  $(function () {
     var formfieldValue = window.parent.Xrm.Page.getAttribute("CRMFieldSchemaName").getValue();
  });
</script>



回答2:


That box is for static values. To make it dynamic you need to construct the IFRAME URL using Javascript.

I used XrmIframe as framework in order to make Iframe coding simple. The important part happens in the OnLoad Event.

Keep in mind that this is just a basic example.

//SDK Iframe helper example
function XrmIframe(sId) {
    if (sId == undefined) return;

    var xiObject = this;
    xiObject.Ctl = Xrm.Page.getControl(sId);

    xiObject.Get = function () { 
        return xiObject.Ctl.getSrc(); 
    }

    xiObject.Set = function (sUrl) { 
        xiObject.Ctl.setSrc(sUrl); 
        return xiObject; 
    }               
}

//entity onload js
var myIframe;
function OnLoad() {
    //construct iframe
    myIframe = new XrmIframe("IFRAME_Test");
    //load iframe
    myIframe.Set("construct url with dynamic values here...")
}


来源:https://stackoverflow.com/questions/25140293/passing-dynamic-parameter-field-values-to-webresource-on-dynamics-crm-using-cu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!