Hi guys,
I have a piece of Javascript that creates a unique URL to open a report based on the Account name, however it's failing when the name includes an Ampersand. I have realised that I need to replace the ampersand in the name with the hex code %26 in order for it to work, but I'm not 100% on how to update my function. For reference, the current function is below:
function OpenUrl() {
var nameAttr = parent.Xrm.Page.data.entity.attributes.get("name");
if (nameAttr !== null) {
var name = nameAttr.getValue();
var url = "myserver/.../ReportViewer.aspx;Client=" + name + "&rs%3aCommand=Render";
window.open(url);
}
Any help appreciated!
*This post is locked for comments
Hi Aric, the name field is just the Account Name, which is used to generate the direct link to the SSRS report. I've tested this in my sandbox and it seems to be working fine, not sure of any potential downsides to this approach?
What kind of data do you have in the name field? Is it just the possibility of having the & in it.
The encodeURI might work, but the question is when you will be decoding it...
Just to follow up on this, I think the solution might be to replace the "name" attribute in the "var url" line with encodeURIComponent(name), but I'd appreciate someone else confirming that for me
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156