Redirect to URL with URL Encoding for Special Characters

  • 1
  • Question
  • Updated 4 years ago
  • Answered

I am trying to create a Clone button that redirects to a URL and I am passing the following parameters, see below .  All parameters are separated by the & symbol (ampersand special character).  My problem is that one of the values I am passing contains a & symbol.  Is there a way to tell Skuid to automatically URL Encode the values before passing to the URL string?

PumpType={{Pump_Type__c}}&CareArea={{Care_Area__c}}&OtherPumpType={{Other_Pump_Type__c}}&DateOfGoLive={{Date_of_Go_Live__c}}



Photo of Jeffrey Lawler

Jeffrey Lawler

  • 1,454 Points 1k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, there is a global merge function you can use called encodeUrl that will achieve this.

Assuming that "Care Area" is the parameter that can contain URL-unsafe characters, do this:

PumpType={{Pump_Type__c}}&CareArea={{#encodeUrl}}{{Care_Area__c}}{{/encodeUrl}}&OtherPumpType={{Other_Pump_Type__c}}&DateOfGoLive={{Date_of_Go_Live__c}}

For more info on these merge functions, see the API docs on Global Merge Variables / Functions.
Photo of Jeffrey Lawler

Jeffrey Lawler

  • 1,454 Points 1k badge 2x thumb
Excellent!  Thank you very much!
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
I believe you can surround your parameters with {{urlEncode}} to get that effect.Or you might have to do something like this: PumpType={{#urlEncode}}{{Pump_Type__c}}{{/urlEncode}}. I guess you can try both...
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
I was pretty close! Zach's just really fast... 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Thanks Moshe, I should leave posts untouched for 30 minutes to give you a chance to answer first :)
Photo of Jeffrey Lawler

Jeffrey Lawler

  • 1,454 Points 1k badge 2x thumb
This site provides EXCELLENT support.   Thanks to both of you.