skuid.utils.mergeAsText() unexpectedly escaping ampersand

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:

$&#46;each(userActions, function (i, row) {<br /> var btn = actionsModel&#46;getRowById(row&#46;Action_Button__c);<br /> if (btn) { var itemUrl = skuid&#46;utils&#46;mergeAsText('row', btn&#46;Skuid_Url__c, null, accountModel, account); if (btnEnabled) { launchItem = $(document&#46;createElement('a')) &#46;addClass('launch-item') &#46;attr('href', itemUrl) &#46;attr('target', '_blank') <i> &#46;appendTo(launchContent)</i><br />

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&amp;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/t/special-characters-replaced-with-unescaped-characters-on-sk…

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

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&amp;Id={{Id}}”) the character is not double-escaped as you might expect (the result is still “/apex/skuid__ui?page=Portal&amp;Id=000000000000000000”, not “/apex/skuid__ui?page=Portal&amp;amp;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:

&nbsp; &nbsp; var itemUrl = skuid.utils.mergeAsText('row', btn.Skuid_Url__c, { createFields: false }, accountModel, account);<br>

I will talk to our documentation team and see how we can best communicate this change in behavior.

thank you for the feedback, I just tested that second option & confirmed adding {createFields: false} does resolve our issue