Power Automate Convert a String to GUID

Convert a string to GUID in Power Automate

Suppose you need to create a new globally unique identifier (GUID). In that case, Power Automate provides guid() function which generates and returns a new GUID as string. It is a useful function, but it doesn’t create a GUID based on string we provide, the way it works in C#. This post will explain how to convert a string into GUID format with dashes (with or without curly braces).

I m making this cloud flow manually triggerable for the sake of post, initializing a variable with the GUID string.

Next, I m converting this string to GUID (with dashes) using expression and storing in a variable.

Here is expression I used, for me variable name is StringGuid, please change as per your situation.

concat(substring(variables('StringGuid'),0,8),'-',substring(variables('StringGuid'),8,4),'-',substring(variables('StringGuid'),12,4),'-',substring(variables('StringGuid'),16,4),'-',substring(variables('StringGuid'),20,12),'')

Same way to convert this string to a formated GUID with curly braces I m using this expression with a variable.

Here is expression to generate GUID with curly braces

concat('{',concat(substring(variables('StringGuid'),0,8),'-',substring(variables('StringGuid'),8,4),'-',substring(variables('StringGuid'),12,4),'-',substring(variables('StringGuid'),16,4),'-',substring(variables('StringGuid'),20,12),''),'}')

Output:

I hope you found this post helpful. If you like to see this available as a feature please vote this idea.

Let’s Connect

 twIcon lnIcon fbicon

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

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