URL encoding and decoding

Use encodeURIComponent instead of encodeHTML — encodeHTML is not appropriate here.

Thanks Zach. I used encodeURIComponent and now it shows KEVIN O'BRIEN in that lookup field.

 However I can save the record without any error and then offcourse it changes to proper name after save. But it should display KEVIN O’BRIEN before saving.

I think Lookup field or the model condition is not interpreting/decoding the name properly. when I checked resultant encoded URL; for O’BRIEN it becomes O%26%2339%3BBRIEN. And in the field it shows O'BRIEN. I tried nameString = nameString.replace(‘%26%2339%3B’, “'”); but the field shows O’BRIEN. Pls help.

We would need to see the exact setup of the portion of the source and target pages in question in order to help any further — I tried what I believe you are doing and could not replicate the problem, the Model Conditions are doing what they should be doing. I believe that the source of the error is that you are trying to encode an already-encoded value. Normally, values in Skuid Model data are stored encoded, but depending on where you are getting the value you from, you may be “double encoding” it. How are you passing / converting values into the URL? Do you have a Button that is running some custom JavaScript, and is this JavaScript opening the new URL? If so, please post exact lines of JavaScript that are being called. If you are using a Redirect to URL action and your URL is defined by a Template, please post the full URL template you are using.

Here is the XML for a sample page that I used to test to show that this was working:

New {{Model.label}} {{Model.labelPlural}}

And here is a sample JavaScript Snippet i used to test with various dummy values:

var newValue = window.prompt(‘Enter the name to pass in’,‘KEVIN O’BRIEN’);

skuid.utils.redirect({
url: ‘/apex/skuid__ui?page=LookupFieldPopulation&accid=001G000000sgyKLIAY&accname=’+newValue+‘&subject=’+newValue
});

I am calling a js snippet from global action on a related list. The snippet generates URL and redirection happens. Below is a url string generation part from my snippet. Let me know if you need whole snippet and I can email it to you:


//URL string generation starts 
var urlSub = “/apex/skuid__ui?page=PKY_CDocument&pageMode=new&isDoc=true&mnId=”+cModel.data[0].Business_Account__c+“&mainDocId=”+cModel.data[0].Id;

urlSub += “&mainDocType=”+mainDocType+“&rDate=”+todaysDate;

//I encoded String below. I tried without encoding too
var nameString = encodeURIComponent(cModel.getFieldValue(cRow, EmplNameFld));
// nameString = nameString.replace(‘%26%2339%3B’, “'”);

//I am generating parameter names dynamically here and assigning values too
urlSub += “&”+Employees[i]+“Id=”+cModel.getFieldValue(cRow, EmplIdFld)+“&”+Employees[i]+“Name=”+nameString;

console.log(urlSub);
window.top.location = urlSub;


1) When cModel.getFieldValue(cRow, EmplNameFld) has KEVIN O’BRIEN and I generate URL without encoding then the skuid page shows Kevin O in field after redirection.

2) If I encode this string and generate URL then it shows KEVIN O'BRIEN in the lookup field after redirection.

I have conditions on my model(for both ID and Name) which takes these param values. I checked soql it looks good. That is why I am able to save the record without any error. It is just that the value before saving the record does not look proper in the field.

There’s a third parameter in skuid.model.Model.getFieldValue() shown here.

Try to put true in that third parameter like this.

cModel.getFieldValue(cRow,EmplIdFld,true);

We escape the value from getFieldValue by default to prevent people from inadvertently letting XSS vulnerabilities into their page.  If you use the noEscape attribute, you have to be careful not to just throw that into your html somewhere though. (Your code looks fine, but just a friendly reminder.) :slight_smile:

I tried. It shows correct name in lookup field- KEVIN O’BRIEN.
However, the skuid pages shows problem on top. It is a problem with soql formed. It is a record creation page and the soql formed has Negotiator__r.Name = ‘KEVIN O’BRIEN’   which creates a problem. This is coming from model condition.

What version of Skuid are you running?

6.8.7

Hmmm, that sounds strange. I’ll try to recreate in my org, if you wouldn’t mind granting Skuid access to your org by following the instructions below, I may be able to figure it out sooner.

http://help.skuidify.com/m/getting-started/l/182412-getting-help-how-to-grant-skuid-login-rights-to-…

I’ll also need your org Id and page name if you want me to take a look at your setup.  You can send that in an email to support@skuidify.com

Actually nevermind. I’m able to reproduce this issue.  I’ll look into it more and let you know what I find.

Thanks Ben! However I will have to check on sharing this info tomorrow with our admin. Company policy might restrict it. I will be in touch with you on your email tomorrow morning PST. Hope this time suits you.

OK, thank you!

Ok, we were able to replicate this issue and it is a bug in Skuid.  We’ll put out a patch later this week to fix this.

Ok, thank you. I will follow up on this patch offline through email.

This has been fixed in Skuid 6.8.8 available on the Skuid Releases page.

http://www.skuidify.com/skuidreleases

Hi Ben,
I upgraded Skuid to 6.8.8 and checked this issue. It still shows incorrect name in lookup field.
I used cModel.getFieldValue(cRow,EmplIdFld,true) and passed this string in URL. The employee name KEVIN O’BRIEN displays in lookup field as KEVIN O’BRIEN. The pages shows no erros and saves properly.