Search code examples
dynamics-crmmicrosoft-dynamicspowerappsdynamics-365

How to pass a parameter to set column record value with an ampersand (&) in the extraqs arguments


From a PowerBI Report and from a Canvas App I would like to open new contact form within Dynamics 365.

So I create a URL with that will navigate the user to Dynamics. But in that URL I want to pass parameters do not all data needs to be filled in by the user.

Normally I use the extraqs argument. Documentation

But now I'm facing this issue, that passing the ampersand (&) as a value will give an generic error because Dynamics cannot parse the extraqs argument.

For example create a new contact for the account "Bar & Restaurant". So in the extraqs parameters should be: parentcustomerid: 00000000-0000-0000-0000-000000000001 parentcustomeridname: Bar & Restaurant

This URL doesn't work: https://environmentname.crm4.dynamics.com/main.aspx?appid=00000000-0000-0000-0000-000000000000&etn=contact&newWindow=true&pagetype=entityrecord&extraqs=parentcustomerid%3D%00000000-0000-0000-0000-000000000000%7D%26parentcustomeridname%3DBar & Restaurant

This URL does work: https://environmentname.crm4.dynamics.com/main.aspx?appid=00000000-0000-0000-0000-000000000000&etn=contact&newWindow=true&pagetype=entityrecord&extraqs=parentcustomerid%3D%00000000-0000-0000-0000-000000000000%7D%26parentcustomeridname%3DBar Restaurant

I know there are escape characters like %26, but those don't work in extraqs arguments. So my question is, how to pass a parameter to set column record value with an ampersand (&)?


Solution

  • As per the documentation link you provided -

    You must encode the parameters passed in the extraqs parameter. To encode the parameters, use encodeURIComponent. To use special characters like "=" or "&" in the parameter values, you must double encode (e.g. to set name to A=B&C, it would be extraqs=name%3DA%253DB%2526C).

    So & should be double-encoded to %2526