String Changers: URL Encoding and Number Formatting

Suppose you need a way to easily take a string with spaces and URL-encode it so you can put it in a URL (for example: ‘my cat’ becomes ‘my+cat’). You also have some numbers in string form that you want 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:

You can install these from here.

The source code is available here and is a great template to convert other Apex string functions.