Pass Custom Parameters to The HTML Web Resource through Iframe -XRM2011

Pass Custom Parameters to The HTML Web Resource through Iframe -XRM2011

Pass XRM Form Data to the web resource as Custom Parameters as follows:

function SendCustomUrlToIframe(ifarmeUrl, iFrame) {

 var customerId = Xrm.Page.data.entity.getId();

 if (customerId != null) 
{
  Xrm.Page.getControl(iFrame).setSrc(ifarmeUrl + "&id=" + customerId); 
}
}

Another Example:

The following sample shows you how to set the src property for the IFRAME and any parameters by using the onChange event of an option set field.

//Get the value of an option set attribute
var value = Xrm.Page.data.entity.attributes.get("new_pagechooser").getValue();
var newTarget = "";
//Set the target based on the value of the option set
switch (value) {
    case 100000001:
        newTarget = "http://myServer/test/pageOne.aspx";
        break;
    default:
        newTarget = "http://myServer/test/pageTwo.aspx";
        break;
}
//Get the default URL for the IFRAME, which includes the 
// query string parameters
var IFrame = Xrm.Page.ui.controls.get("IFRAME_test");
var Url = IFrame.getSrc();
// Capture the parameters
var params = Url.substr(Url.indexOf("?"));
//Append the parameters to the new page URL
newTarget = newTarget + params;
// Use the setSrc method so that the IFRAME uses the
// new page with the existing parameters
IFrame.setSrc(newTarget);
Cheers,
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s