Most of my life I have been a traditional developer, primarily working with C#.
C# has a neat function called String.Join
.
This function allows the caller to pass in an array of values and a separator character and then returns those results has a concatenated string with each array value separated with the separator character.
For example, if you were to pass in the values "Star Trek", "Star Wars", "Lord of the Rings"
and a separator character of ", "
, a comma, it would return the string "Star Trek, Star Wars, Lord of the Rings"
.
Switching to the Power Platform.
Power Automate also has a expression called join
which does the same thing as the C# function.
The one problem I need to deal with it sometimes empty values are provided in the array, and I needed to ignore those, which the join
expression would not do, so I decided to write a flow that could be called from other flows.
In my first version I handled all the logic, looping through all the array values, checking to see if it was empty, if it wasn’t, checking to see if it was the last item, and if it wasn’t then appending the separator character.
Turned into quite an extensive flow.
In my second version I deferred as much of the works as a could to existing actions.
I leaned on the Data Operations connector and used Filter
to get a list of non-empty values and then used Join
to create a string from the array.
This looked a lot cleaner, more in the spirit of low-code and easier to maintain.
Check flow out for yourself, download it at HelpersSolution_1_0_0_1.zip.
Discover more from Matt Ruma
Subscribe to get the latest posts sent to your email.