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!
Hi, just wanted to say, I loved this post. It was helpful.
Keep on posting!
It’s an amazing piece of writing in favor of all the online users; they will obtain benefit from it I
am sure.
There’s a supported way of doing this. Just edit the Sitemap XML and add ‘PassParams=”true”‘ to the SubArea element or edit the Customizations XML and add ‘PassParams=”true”‘ to the NavBarItem element.
See here: http://msdn.microsoft.com/en-us/library/gg328374.aspx and http://msdn.microsoft.com/en-us/library/gg328202.aspx
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!