Express Yourself: String Functions in Microsoft Flow

In this post, I will discuss all the String functions that can be used in Microsoft Flow. As the name implies, the functions covered in this post only apply to String data type.

Function
Description
concat
This function combines any number of strings together. It requires 2 or more parameters in the form of strings to combine into a single string.
Function: concat(text_1, text_2?,…)
Example: concat(‘string1-’,’string2-,’string3’)
Output: string1-string2-string3
Additional Examples: Click here
substring
This function returns a subset of characters from a string. It requires 3 parameters: the string from which the substring is taken; the index where the substring begins; and the length of the substring. The last two parameters are numbers.
Function: substring(text, startIndex, length)
Example: substring(‘This is a short string’,10,5)
Output: short
Additional Examples: Click here
replace
This functions replaces a string with a given string. It requires 3 parameters: the base string that contains the string to be searched for using parameter 2 and then updated with parameter 3; the string to search for; and the string to replace the string from parameter 2.
Function: replace(text, oldText, newText)
Function: replace(‘This is the old string’, ‘old’, ‘new’)
Output: This  is the new string
Additional Examples: Click here
guid
This function generates a globally unique string (GUID). An example of this function is if a document requires a unique ID. It contains an optional parameter, which is a single format specifier that indicates how to format the GUID. The format parameter can be “N”, “D”, ‘B’, “P”, OR “x”. “D” is used by default if the format is not provided.
Function: guid()
Output: c2ecc88d-88c8-4096-912c-d6f2e2b138ce
Examples: Click here
toLower
This function converts a string to lowercase. This function only required 1 parameter, which is the string that needs to be converted to lowercase.
Function: toLower(text)
Example: toLower(‘Microsoft Flow Is AWESOME!!!’)
Output: Microsoft flow is awesome!!!
Additional Examples: Click here
toUpper
This function converts a string to uppercase. This function only required 1 parameter, which is the string that needs to be converted to uppercase.
Function: toUpper(text)
Example: toUpper(‘microsoft flow is awesome!!!’)
Output: MICROSOFT FLOW IS AWESOME!!!
Additional Examples: Click here
indexOf
This function finds the index of a value within a given string case insensitively. This function requires 2 parameters: the string that contains the value and the value to search the index of.
Function: indexOf(text, searchText)
Example: indexOf(‘Microsoft Flow’, ‘Flow’)
Output: 10 (this is the index)
Additional Examples: Click here
lastIndexOf
This function finds the last index of a value within a given string case insensitively. This function requires 2 parameters: the string that contains the value and the value to search the index of.
Function: lastIndexOf(text, searchText)
Example: lastIndexOf(‘Is this vehicle sold as-is?’, ‘is’)
Output: 24 (this is the last index of the word ‘is’, which is found in
‘as-is’)
Additional Examples: Click here
startsWith
This function checks if a string starts with a given value case insensitively. This function requires 2 parameters: the string that contains the value and the value the string may start with. The output is Boolean (true or false).
Function: startsWith (text, searchText)
Example: startsWith(‘This is Microsoft Flow’, ‘This’)
Output: true
Additional Examples: Click here
endsWith
This function checks if a string ends with a given value case insensitively. This function requires 2 parameters: the string that contains the value and the value the string may end with. The output is Boolean (true or false).
Function: endsWith (text, searchText)
Example: endsWith(‘This is Microsoft Flow’, ‘Flow’)
Output: true
Additional Examples: Click here
split
This function splits the string using a separator. This function requires 2 parameters: the string to split and the separator. In the example below, the separator is the space between the words.
Function: split(text, separator)
Example: split(‘This is Microsoft Flow’, ‘ ‘) – there’s a space between the single quotes.
Output: [“This”, “is”, “Microsoft”, “Flow”]
Additional Examples: Click here

Photo by Pankaj Patel on Unsplash

21 thoughts on “Express Yourself: String Functions in Microsoft Flow

    1. Hi dgurgesser,

      You can use the substring() function. You can do it this way: substring(‘descriptionField’, 0, 140). descriptionField is the field that contains the string; 0 is your starting index; and 140 is the length of characters you want to retrieve from the descriptionField. Please try that and let me know.
      Thank you!

      Like

  1. How can I split based on a carriage return. I am trying to separate a lookup field with multiple values into separate SharePoint columns and the values are put on separate lines

    Like

    1. Hello jrtraylor,

      You can add a Compose or an Initialize variable actions and to set it’s value, press Enter. Then when using the split() function, you can do an expression similar to this: if using a Compose action, do split(StringToSplit, outputs(‘Compose’)) and if using a Variable, do split(StringToSplit, variables(‘variableName’)). Please try that and let me know.

      Thanks.

      Like

      1. Thank You for the response. I ended figuring out that the output of the multichoice column and lookup column with multiple values is actually an array. I was looking at the result in the column and just started thinking I had a line break to deal with. So I initialized an array variable and appended it with the values of the lookup column. I was then able to place the index of the array into the columns of the SharePoint List.

        Liked by 1 person

  2. Hello Fausto, I am trying to get the first 4 characters and want to filter on them.
    If I write this down it gives me an error:

    @equals(first(body(‘Get_items’)?[‘value’])?[‘Name’],’0202′)

    Can you help me out with this?

    Like

  3. Hi, thanks for replying.
    Actually, it will be multiple number of leading zero
    Ex :- 0000000678040
    Need a result:- 678040

    Like

  4. Hello Fausto,

    I am trying to remove “Review & Acknowledgment Required – “, from a dynamic content that looks like “Review & Acknowledgment Required – CHG0257429”, But the CH####### changes every time

    Like

    1. Hi Tarik,

      You can achieve what you need by combining the last() and the split() functions in an expression. For example, you can do an expression as follows: last(split(YourDynamicContentValue, ‘ – ‘)). The split() function will split the string at the – , including the spaces in both its left and right side, and the last function will grab the string to the right after the split(), similar to the RIGHT() function in Excel. I have a blog post where I use a similar expression, here’s the link: https://faustocapellan.com/2019/07/15/how-to-1-rename-email-attachments-using-microsoft-flow/

      Like

  5. Dude. DUDE. This is the most helpful page I have found related to Automate thus far — and I have sifted through hundreds of sites, fourms, and posts. Seriously, my heat is bursting. Thank you so much for all this.

    Like

  6. Hey,
    How can I put concatenate a string with the replace function? I need to replace the html from a create HTML action to format the table a bit. I want to add a header row with dynamic content, but can’t seem to get the expression right.
    replace(body(‘Create_HTML_table_-_Core_Team_L09A’),”,’@items(‘Apply_to_each’)?[‘Country_x0020_or_x0020_Cluster/Value’]Core Team’)
    I need the text of my second to be items(‘Apply_to_each’)?[‘Country_x0020_or_x0020_Cluster/Value’].

    Like

  7. Hey,
    How can I insert a space into a string field? I don’t need it in a specific place, just a space somewhere in the text. 5491141637426 –> 54 91141637426

    Like

    1. Hi saramargolisshellcom,

      You will have to do several expressions to get to this. To make sure it works, use a Compose action for every of the expressions listed below:

      1. In the first Compose action, get the first 2 characters from the string using an expression as follows:
      substring(string(outputs(‘String’)), 0, 2).
      **Note: this part of the expression (string(outputs(‘String’))) comes from the output of a Compose action I am using to store the numbers you
      provided in your comment, and it has to be converted to a string using the string() function.

      2. In the next Compose action, the string must be split with the output from bullet point 1, and using the last() function, retrieve the characters to
      the right of the characters using an expression as follows: last(split(string(outputs(‘String’)), outputs(‘First_2_Characters’))).
      **Note: combining the split() and the last() functions, you can replicate the RIGHT() action from Excel. If you combine split() with first(), you can
      replicate the LEFT() function.

      3. In the last Compose action, you will concatenate the outputs of the first and second Compose actions along with the required space using an
      expression as follows: concat(string(outputs(‘First_2_Characters’)), ‘ ‘, string(outputs(‘Remaining_Characters’))).

      Please try that approach. Thank you!

      Like

Leave a Reply to jrtraylor Cancel reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s