Arnab Bose contacted me this morning and wanted a couple of Flow Actions for transforming strings. He’s building some cool Flow and Quip integrations and needed a way to easily take a string with spaces and URL Encode it so he could put it in a URL (for example: ‘my cat’ becomes ‘my+cat’). He also had some numbers in string form that he wanted to add commas to (i.e convert 2348934 to 2,348,934).
In Apex, these are super simple because of the large library of available functions. To URL encode a string, you just write:
String encoded = EncodingUtil.urlEncode(myString, 'UTF-8');
and to format a string, you can just write:
response.outputStr = Integer.valueOf(inputStr).format()
But the fun part of Flow is not having to write code. So I created a couple of Apex Actions that carry these out:
The source code is available here and is a great template to convert other Apex string functions.