Pass Custom Parameters To WebResource From UIC SiteMap in Dynamics

While working on creating a page to open a Canvas app full screen inside of a Model app I wanted to create a WebResource I could use over and over again. Most of the references I found showed the Canvas app name in the code which wouldn’t allow for code re-use. Instead I wanted to pass query string parameters to the WebResource so that it could get the name from the URL. The problem I ran into was with the new UCI interface and how it handles WebResources. After a bit of trial and error I found the trick was not using the WebResource type in the SiteMap editor but instead using a URL in the correct format and passing the parameters I needed within the Data parameters.

Update- After working with the Maker Portal SiteMap editor I have realized that it will auto decode all of your Data parameters. Instead of using the Maker portal you will need to update the SiteMap using [XrmToolbox] or another XML Editor.

Use XRMToolbox SiteMap editor to create your sub area.
Use XRMToolbox

Do not use the Maker Portal Experience.
Do Not Use Default Sitemap Editor

Here is the correctly formatted URL to use and an example of how to use it.

main.aspx/webresources/<Your WebResource Name>?Data=<Your Parameters URI Encoded>
main.aspx/webresources/raw_CanvasAppInModel.html?Data=CanvasAppName=Test

To encode your parameters just open the console in your browser by hitting the F12 button and run the encodeURIComponent function on your parameters.
EncodeURI

In order to get the values of the Data parameter in your WebResource you can follow the instruction and code from Microsoft in the link below.

Sample: Pass multiple values to a web resource through the data parameter

Comments

  1. Thank you for sharing this post. Are you looking for the best CRM software? CRM software is a platform that helps business owners, from sales to marketing to better customer relationships. From managing lead to workflow automation, complete contact management to performance management, streamline project tasks to invoice management, it helps to boosts sales performance and streamlines business processes.

    ReplyDelete

Post a Comment

Popular posts from this blog

Add User As Local Administrator On Domain Controller

Calling Dataverse Web API in PowerShell using Client Credentials

Windows Server 2008R2 VMs Shut Down After 1 to 2 Hours