skuid.utils.mergeAsText() unexpectedly escaping ampersand

samsam
edited May 24, 2018 in Questions
having a new issue with URLs generated by skuid.utils.meregeAsText() that started escaping "&" differently after we upgraded to skuid v11.1.13.

Prior to v11, we were able to generate URLs from this code:
 $.each(userActions, function (i, row) {
var btn = actionsModel.getRowById(row.Action_Button__c);
if (btn) { var itemUrl = skuid.utils.mergeAsText('row', btn.Skuid_Url__c, null, accountModel, account); if (btnEnabled) { launchItem = $(document.createElement('a')) .addClass('launch-item') .attr('href', itemUrl) .attr('target', '_blank') .appendTo(launchContent)
console.log for the template in that mergeAsText function returns "/apex/skuid__ui?page=Portal&Id={{Id}}" but itemUrl returns "/apex/skuid__ui?page=Portal&Id=000000000000000000"

no other special characters are escaped in the URLs we are generating like this and it's new, so it seems like unexpected behavior (and it's messing up our URLs to redirect to other skuid pages).  also seems related to:

https://community.skuid.com/skuid/topics/special-characters-replaced-with-unescaped-characters-on-sk...

https://community.skuid.com/skuid/topics/skuid-11-1-13-picklist-bug-withspecial-characters

Comments

  • JD BellJD Bell ✭✭
    edited May 23, 2018
    I have been able to reproduce this behavior in the latest version of Millau.

    This is due to some structural changes to the underlying API. We documented some of the changes in our release notes, but unfortunately it looks like this particular use-case was missed. The issue is related to how we handle the double-curly-braces as merge variables. I believe that in prior versions of Skuid we did not format double-curly-brace merge variables when merging as text. We now format those fields (to be more consistent with other use-cases), but this requires generating a UI Field which in turn requires a trip through the DOM. Some browsers, in an effort to be helpful, "correct" un-escaped characters such as ampersands. Note that if you escape the ampersand yourself (with a template such as "/apex/skuid__ui?page=Portal&Id={{Id}}") the character is not double-escaped as you might expect (the result is still "/apex/skuid__ui?page=Portal&Id=000000000000000000", not "/apex/skuid__ui?page=Portal&Id=000000000000000000"). Skuid is not doing this explicitly, but it is an unfortunate side-effect of using UI Fields.

    To restore the prior behavior, you have two options:

    1. You can use a triple-curly-brace merge variable in the template, which will not apply field formatting: /apex/skuid__ui?page=Portal&Id={{{Id}}}
    2. You can pass in an option object with "createFields" set to false, which will also prevent field formatting: skuid.utils.mergeAsText(mode, template, { createFields: false }, model, row)

    Given your use-case, I believe that the following would be most appropriate:
        var itemUrl = skuid.utils.mergeAsText('row', btn.Skuid_Url__c, { createFields: false }, accountModel, account);
    I will talk to our documentation team and see how we can best communicate this change in behavior.
  • samsam
    edited May 31, 2019
    thank you for the feedback, I just tested that second option & confirmed adding {createFields: false} does resolve our issue
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!