Example of a long replace function:

replace(replace(replace(replace('[{"Value":"Maintenance/Warranty"},{"Value":"Product"},{"Value":"Other Product"},{"Value":"Resale"}]', '{"Value":"', ''), '"}', ''), '[', ''), ']', '')

The expression above removes several symbols to make the list easier to read

BEFORE:

[{"Value":"Maintenance/Warranty"},{"Value":"Product"},{"Value":"Other Product"},{"Value":"Resale"}]

AFTER:

Maintenance/Warranty,Product,Other Product,Resale

Creating long expressions can get confusing so here is my method:

  • Lookup how to use the expression
  • In notepad I then paste my ugly array format and then below it I paste the syntax example
    • [{“Value”:”Maintenance/Warranty”},{“Value”:”Product”},{“Value”:”Other Product”},{“Value”:”Resale”}]
    • replace(‘the old string’, ‘old’, ‘new’)
  • I use those two lines at the top of the notepad as a reference
  • Next copy the string syntax on a new line and fill in the blanks with your array info and what you want to remove
    • replace(‘[{“Value”:”Maintenance/Warranty”},{“Value”:”Product”},{“Value”:”Other Product”},{“Value”:”Resale”}]’, ‘{“Value”:”‘, ”)
      • The above will remove {“Value”:” from the first part of my array
      • I then create a power automate schedule flow so I can manually run the test
      • Create a compose action and on the expressions tab paste the above info in, press OK, save, and run
      • You can then look at your output in the log to see if anything was wrong
      • If all worked well then I add a -Works after that code and copy paste the code to a new line
    • replace(‘[{“Value”:”Maintenance/Warranty”},{“Value”:”Product”},{“Value”:”Other Product”},{“Value”:”Resale”}]’, ‘{“Value”:”‘, ”) -Works
  • Now I want to remove MORE symbols so I have to add another replace function over this one above like so:
    • replace(replace(‘[{“Value”:”Maintenance/Warranty”},{“Value”:”Product”},{“Value”:”Other Product”},{“Value”:”Resale”}]’, ‘{“Value”:”‘, ”), ‘”}’, ”)
      • Above in bold you can see I added another replace outside of the previous code
      • I test this code in composer and then add -Works at the end and copy the code to a new line
  • Again we remove more symbols
    • replace(replace(replace(‘[{“Value”:”Maintenance/Warranty”},{“Value”:”Product”},{“Value”:”Other Product”},{“Value”:”Resale”}]’, ‘{“Value”:”‘, ”), ‘”}’, ”), ‘[‘, ”)
      • Above in bold has been added outside the previous code
      • Test in composer
  • I did the above method one more time to get the code at the very top of this post
  • Once you have the code you want you can then remove the static variables in the example above and select dynamic content
    • replace(replace(replace(replace(outputs(‘Compose_2’), ‘{“Value”:”‘, ”), ‘”}’, ”), ‘[‘, ”), ‘]’, ”)