web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

decodeURIComponent adding chars to string Unified Interface

(0) ShareShare
ReportReport
Posted on by 190

We use encodeURIComponents to pass parameters to a html web resource. We use decodeURIComponent in the HTML web resource to get the string and we split it to an array at the & chars (26). This works fine in the old legacy UI but when testing in the ne Unified Interface the chars '25' are getting added to the string parameter after each '%' char. In the old UI the parameter looks like this after we pass it to the function decodeURIComponent:

  • Phil%20Crocker%26test%2640472B11-122B-EA11-A810-000D3A86A78C

but in the Unified Interface the string looks like this after it is passed to the same function:

  • Phil%2520Crocker%2526null%2526B184FA94-0E2B-EA11-A810-000D3A86AD25 (ignore the 25 at the end of the GUID - it is a coincidence)

I am using Xrm.Navigation.openWebResource to open the web resource and pass the string parameter. The string parameter is built up like this:

  • var params = currentUserName + "&" + resolveComments + "&" + caseId;

Here is the code used:

This opens the web resource and passes the string parameter:

//Open Resolve case form
function OpenResolveCaseForm(caseId, currentUserName, resolveComments)
{
debugger;
    var params = currentUserName + "&" + resolveComments + "&" + caseId;
    var customParameters = encodeURIComponent(params);
    var windowOptions = { height: 200, width: 500 }
    Xrm.Navigation.openWebResource("pol_ResolutionForm", windowOptions ,customParameters);
}

This converts the string to an array and should contain 3 seperate string objects:

  1. System User name
  2. Text for text box
  3. Case record ID

function getDataParam() {
            debugger;
            var vals = new Array();
            if (location.search != "") {
                vals = location.search.substr(1).split("&");
                for (var i in vals) {
                    vals[i] = vals[i].replace(/\+/g, " ").split("=");
                }
                var found = false;
                for (var i in vals) {
                    if (vals[i][0].toLowerCase() == "data") {
                    parseDataValue(vals[i][1]);
                       found = true;
                        break;
                    }
                }
                
            }
            
            }       

        function parseDataValue(datavalue) {
            debugger;
            if (datavalue != "") {
                var vals = new Array();               
                vals = decodeURIComponent(datavalue).split("&");
                for (var i in vals) {
                    vals[i] = vals[i].replace(/\+/g, " ").split("=");
                }
                document.getElementsByName("ResolvedBy")[0].value = vals[0];
                if (vals[1] == null || vals[1] == "" || vals[1] == undefined || vals[1] == "null") {
                    document.getElementsByName("comment")[0].value = "";
                }
                else {
                    document.getElementsByName("comment")[0].value = decodeURIComponent(vals[1]);
                }
                caseId = vals[2];
            }
        }

Anyone else experiencing this behaviour or have an idea why this functionality has changed with the Unified Interface

Thanks

Phil

I have the same question (0)
  • Suggested answer
    Henry J. Profile Picture
    5,237 on at

    Hi Phil,

    It looks like your string is encoded twice:

    Without encoding: Phil Crocker&test&40472B11-122B-EA11-A810-000D3A86A78C
    After a 1st encoding: Phil%20Crocker%26test%2640472B11-122B-EA11-A810-000D3A86A78C
    After a 2nd encoding: Phil%2520Crocker%2526test%252640472B11-122B-EA11-A810-000D3A86A78C

    I have no idea if this expected in Unified Interface, so I would open a Support Request: https://admin.powerplatform.microsoft.com/support

    On a side note, I see you are trying to replace the default Case Resolution logic with a custom Web Resource.
    You might to keep an eye open for the 2020 Release Wave 1, as 2019 Release Wave 2 introduced this for opportunities: 
    https://docs.microsoft.com/en-us/dynamics365-release-plan/2019wave2/dynamics365-sales/customization-opportunity-close-dialog-box

    Also, have you had a look at the navigateTo method? It could be of interest to you, although it has some limitations, as highlighted in this article:
    https://butenko.pro/2019/12/23/xrm-navigation-navigateto-gotchas-tricks-and-limitations/

    Henry

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 76

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 47 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 40 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans