Flow Actions for Strings: URL Encoding and Number Formatting

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:

You can install these from here.

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

1 reply
  1. Narender Singh
    Narender Singh says:

    To avoid calling Apex, we can also create lightning component as flow actions and use JS to handle the encoding and formatting.
    I wonder which one would be faster though! IMO, it should be the component.

    Using component would also give us an added advantage of no Test Class for deployment.

    Though flow action will only be available in Screen flows.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply