One of the reasons I do this blog is so that I can find all the nice tips, tricks and scripts again after I’ve used them. As such, I end up re-blogging what some other kind souls have already done, this is one of those.
Scenario: You have a string that you want to use as part of a URL in Microsoft Flow
Issue: It’s a free text box, and users can add in spaces and special characters.
Solution: Create a variable and set it to the following expression:
Replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(triggerBody()?['Title'],':',''),'%',''),'#',''),'*',''),'<',''),'>',''),'?',''),'/',''),'"',''),'"',''),'@',''),'&',''),'=',''),'/',''),';',''),'|',''),'\',''),'[',''),']',''),'~',''),'{',''),'}',''),'^',''),'!',''),',',''),'.',''),' ','')
NOTE: this will take the Title field of the triggering item and remove the special characters and spaces.
Originally found at this blog post: https://blog.mydock365.com/easy-way-to-convert-string-to-a-url-friendly-string-using-microsoft-flow