function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex YhapAlex Yhap 

Merged fields with parameters in Custom Button

I have a Custom Button:
https://workflow.congamerge.com
?SessionId={!API.Session_ID}
&ServerUrl={!API.Partner_Server_URL_80}
{!causeview__Receipt__c.Conga_Solution_URL__c}
&DS7=12
&BML=Sending+Receipt+For:+{!causeview__Receipt__c.causeview__Constituent__c}

That is passed this value Conga_Solution_URL__c:
&id=a0qq0000000gQue&EmailToId=003q000000J9l8S&CongaEmailTemplateId=a1Uq00000002E42&templateId=a1Wq00000001baX&FP0=1&LG3=1&AC0=1&SC0=1&SC1=Attachments&QMode=SendEmail

Which is results in:
https://workflow.congamerge.com/composer8/index.html?SessionId=00Dq0000000B2gd%21ARgAQEjKPP.PA2DmTqONE9W3qyo.yAhg0kqHWWIadleiv6Ww_0g7C7PSl7TON8j4as1J9K06SXbJx_rDqFamoW7lFh7XTQn1&ServerUrl=https%3A%2F%2Fcs21.salesforce.com%2Fservices%2FSoap%2Fu%2F8.0%2F00Dq0000000B2gd%26id%3Da0qq0000000gQue%26EmailToId%3D003q000000J9l8S%26CongaEmailTemplateId%3Da1Uq00000002E42%26templateId%3Da1Wq00000001baX%26FP0%3D1%26LG3%3D1%26AC0%3D1%26SC0%3D1%26SC1%3DAttachments%26QMode%3DSendEmail&DS7=12&BML=Sending+Receipt+For:+Alexander+Yhap

As you can see the text is being encoded which I do not want. "&" is being converted to "%26" and "=" is to "%3D". I DO NOT want this action to occur...

How do I prevent the merged field from being html encoded?

Thanks
Best Answer chosen by Alex Yhap
Alex YhapAlex Yhap
Got it...Changed the content source the "On Click Javascript" and changed the syntax abit.
window.open('https://workflow.congamerge.com?SessionId={!API.Session_ID}&ServerUrl={!API.Partner_Server_URL_80}{!JSENCODE(causeview__Receipt__c.Conga_Solution_URL__c)}&DS7=12&BML=Sending+Receipt+For:+{!causeview__Receipt__c.causeview__Constituent__c}', '_blank');

 

All Answers

Alex YhapAlex Yhap
ignore <b> tags...added automatically when I posted the question.
srlawr uksrlawr uk
Can you try making your merge field use this function:

{!JSENCODE(causeview__Receipt__c.Conga_Solution_URL__c)}

(on both merge fields)

Hopefully the JSENCODE method will make the render return an already safe string and thus won't be encoded (or it might just exacerbate the problem, thinking about it.. I might try it out in a dev edition for you as well!)
Alex YhapAlex Yhap
@srlawr uk That doesn't work...it still html encodes. :(
srlawr uksrlawr uk
rats. So the deal is, you already have your parameters encoded, and stringed up (so your spaces are already %20 for example) - but you don't want your &= bits to be RE-encoded when you put them out?

All the info on encoding is kind of here:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_security_tips_scontrols.htm

There is no scenario in which a string is already basically encoded. Let me think about this. it might be you need to create a second custom field and do a bit of processing to make it more suited for inclusion in a custom button?

Does this happen when you both run it as a URL and a onClick type?
Alex YhapAlex Yhap
Got it...Changed the content source the "On Click Javascript" and changed the syntax abit.
window.open('https://workflow.congamerge.com?SessionId={!API.Session_ID}&ServerUrl={!API.Partner_Server_URL_80}{!JSENCODE(causeview__Receipt__c.Conga_Solution_URL__c)}&DS7=12&BML=Sending+Receipt+For:+{!causeview__Receipt__c.causeview__Constituent__c}', '_blank');

 
This was selected as the best answer
srlawr uksrlawr uk
Excellent. Nice one!