SharePoint Productivity - Dock 365 Blog

Easy way to convert String to a URL friendly string using Microsoft Flow

8/22/18 6:00 AM / by Sajin Sahadevan

Well, this requirement came up for one of our Client that is a Marketing Agency based in Jacksonville, FL. They have a SharePoint list to save external URLs that is used by their team across the United States. Usually, when you convert the URLs from external sources, it comes with special characters like !@$#>% and couple of others. That’s when we found a way to convert such strings into a URL friendly string with the help of Microsoft Flow. Let’s see how this works:

Microsoft_Flow_Home_Screen

You can rely on the Replace function available in Microsoft Flow. This helps you to replace character by another one. In this scenario, we need to replace the special characters with a blank space. When this is done for each character at a time, you can nest them and you will get all the information in a single function.

Let’s create a Title dynamic property with the trigger of characters: [ ] ~ { } ^ ! , .   % # * < > ? / ” @ & = / ; |) \

Copy the below code:

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'],':',''),'%',''),'#',''),'*',''),'<',''),'>',''),'?',''),'/',''),'"',''),'"',''),'@',''),'&',''),'=',''),'/',''),';',''),'|',''),'\',''),'[',''),']',''),'~',''),'{',''),'}',''),'^',''),'!',''),',',''),'.',''

As you see below, a quick Flow can be setup for you to see the results. A 3-easy step procedure and we can get this done in minutes!

  1. When item is created
  2. Initialize Variable
  3. Update Item

Now create a Variable with Friendly URL and update item:

MS_Flow_Workflow_Screenshot

The variable values are the formula we had mentioned earlier, so make sure to update it with the actual string which you need it to be fixed. Copy pasting this will fix Title property of the trigger.

MS_Flow_Workflow_Screenshot_2

The output:

SharePoint_Office365_Group

The previous step didn’t actually help us remove the spaces. So, let’s try another code to remove the spaces too:

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'],':',''),'%',''),'#',''),'*',''),'<',''),'>',''),'?',''),'/',''),'"',''),'"',''),'@',''),'&',''),'=',''),'/',''),';',''),'|',''),'\',''),'[',''),']',''),'~',''),'{',''),'}',''),'^',''),'!',''),',',''),'.',''),' ','')

Here's the output for the above query:

SharePoint_Office365_Group

Make sense? Awesome isn’t it? Give it a try and let us know your experience with Microsoft Flow and SharePoint!

SharePoint & Office 365 Tips

Topics: SharePoint Intranet Portal, Microsoft Flow

Sajin Sahadevan

Written by Sajin Sahadevan

He is a Microsoft Certified Technology Specialist cum Digital Marketing Expert and has experience of 6 years. He loves learning about latest technologies like CRM, collaboration tools, marketing solutions etc.

Dock Social Media:

Sign Up for SharePoint Tips:

    • Dock 365 Intranet Portal
    • Collaborations_yammer
    • Mobile-Power-BI
    • Dock Modern Home
    Microsoft_Partner_Logo.png
    SharePoint Youtube Channels