0

I've looked at a few different articles and the they all seem to suggest the same thing:

"Create a url with the desired query parameters and set the target iFrame with this new Url and have this new page read the request"

I was wondering if there was a way of doing this without the use of a custom ASPX page?

Essentially I would like to dynamically display some text in either an iFrame or html web resource based on some values on the form.

3
  • does window.onload=function() { alert(location.search); } work for you? Commented May 24, 2012 at 7:41
  • you can set iframe url, and after in form load call javascript function, with something like: var userId = crmForm.all.new_id.value; var detailsIframe = crmForm.all.IFRAME_contactdetails; detailsIframe.src = detailsIframe.src + '?Id=' + userID; Commented May 24, 2012 at 11:11
  • 2
    crmForm... notation is deprecated in CRM 2011 Commented May 24, 2012 at 11:27

1 Answer 1

4

There is nothing in the SDK that mandates use of ASPX. In fact in CRM 2011 it is discouraged as you'd need to find somehwere to host your ASP.Net page.

With a basic HTML page (created as a web resource in CRM) you can declare some JScript in the HEAD of the HTML document (or better still, reference a JScript web resource). That JScript could read the querystring parameters sent via the iFrame and do whatever is required from there.

Note that the SDK states that any custom querystring parameters must themselves be encoded and sent via the data parameter.

<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Example page</TITLE>
<META charset=utf-8></HEAD>
<BODY style="BACKGROUND-COLOR: #f6f8fa; MARGIN: 0px; FONT-FAMILY: Segoe UI" contentEditable=true onload="doStuff">
<SCRIPT type=text/jscript>

function doStuff(){
    getQueryStrings();
    alertOrganisationName();
}

function alertOrganisationName(){
    alert(window.parent.Xrm.Page.context.getOrgUniqueName());
}

function getQueryStrings() {
    var message = document.getElementById("myOutputArea");
    var dataParameterString, querystring;
    // get data from querystring
    if (window.location.search != "") {
        querystring = window.location.search.substr(1).split("&");
        for (var i in querystring) {
            querystring[i] = querystring[i].replace(/\+/g, " ").split("=");
        }
        //look for the parameter named 'data'
        for (var i in querystring) {
            if (querystring[i][0].toLowerCase() == "data") {
                dataParameterString = querystring[i][1];
                break;
            }
        }

        message.innerText += dataParameterString;

    } else {
        message.innerText = "No details were specified in the querystring.";
        alert("ERROR: " + message.innerText);
    }
}       
 </SCRIPT>
 <DIV id="myOutputArea"></DIV>
</BODY></HTML>
Sign up to request clarification or add additional context in comments.

1 Comment

Actually I needn't have put that sample together - the aforementioned SDK page example is just as good and also includes deployment instructions if you don't know what you're doing with Web Resources...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.