Passing Query String Parameters to Navigation Link URL

I was recently asked by a client to have a custom .NET page displayed on an entity form. Because of the content of the page (it’s a heavy, long and large!), we were all in agreement that using an IFRAME or a web resource in a Tab or Section on the main form was not going to be pretty. The best user experience is to have the page displayed when users click on a navigation link on the left menu.

Sounds easy, right? Not so fast! In our case, the custom web page displays content that is specific to the record it’s opened from. That means the page needs to know the ID of the record. That sounds easy as well, right? You are thinking simply pass the record ID as parameter in the query string… Yes, it works with an IFRAME and for a Web Resource, you can change the URL programmatically when the form loads or when a field value is changed. For a Navigation Link, not so fast! There is no supported way to change the URL programmatically!

This had me do some research to see what we could do to get around that limitation. Unfortunately, it has to be a non-supported approach.

You could attach to the On Click event of the navigation link or set the URL on load of the form. Regardless, problem is accessing the IFRAME in which your page resides. There are a few ways to do this as you can see here and here. I prefer solution 1 because you use the ID of the navigation URL (it is transported as part of the CRM solution and remains the same in all environments).


Alternatively, you could do it the other way around, meaning accessing the Xrm.Page.data.entity object from the web page in the IFRAME. This is done easily in JavaScript using something like window.parent.Xrm.Page.data.entity.attributes.get(“…”).getValue();. This is also not supported since we have no control over what the parent of the IFRAME window can become.

I want to say I hope Microsoft adds this functionality in a future update but with the new process driven UI forms that are coming in the Orion release, I don’t know if all this will still be relevant in a near future. We’ll see!

Advertisements

6 thoughts on “Passing Query String Parameters to Navigation Link URL

    • Good finding Maarteen. However I believe when you set “PassParams” to true, it only passes information about the organization (org name, language code).

      What I was focusing on here was passing information about the record from which the external web page is being displayed. In my case, the external page showed info about the account (as an example) that is sitting in a different system. In order to identify the account in that other system, I needed its CRM id.

      Cheers

      • Hi Salimadamoon,

        When used in the form navigation this will add the entity type name and the entity id of the current record to the url. So you are wrong in your believe. Try it out and you will see.

        Kind regards,

        Maarten

      • I stand corrected then. I haven’t tested it but I’ll take your word for it! Documentation isn’t very clear, maybe needs an update.

        Happy coding!

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