To create a unique identifier in Power Automate, you can use the “guid()” function, which generates a unique ID. In this tutorial, I will explain how to convert string to GUID in Power Automate.
However, using this function, we can’t create a unique ID based on a specific string. In this Power Automate tutorial, we will see how to turn a regular string into a unique ID(GUID) format that includes dashes and optional curly braces.
Here, we will cover two topics:
- How to convert string to guid using Power Automate
- How to use guid() with parameter in Power Automate
Convert string to guid() using Power Automate
Here, we will see how to convert string to guid() using Power Automate.
In Power Automate, we will Manually trigger the flow and change your string into a unique identifier (GUID) with and without curly braces.
Let’s convert the string to guid by following the below steps:
1. Open Power Automate Cloud, then click on the +Create icon -> select Instant Cloud flow.
Next, provide the flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the “Manually trigger a flow” action is added to the flow page.
2. Now, we will initialize the string variable, where we will assign the string, so click on the +New step -> select the Initialize variable action. Then provide the below information:
- Name: Provide the variable name
- Type: Select String from dropdown
- Value: Provide the value like below
3. Convert the string to guid with or without curly braces in Power Automate. For this, click on the +New step and select Compose action. Then provide the below information:
With curly braces
- Inputs: Provide the below expression:
concat('{',concat(substring(variables('guidString'),0,8),'-',substring(variables('guidString'),8,4),'-',substring(variables('guidString'),12,4),'-',substring(variables('guidString'),16,4),'-',substring(variables('guidString'),20,12),''),'}')
without curly braces
- Inputs: Provide the below expression:
concat(substring(variables('guidString'),0,8),'-',substring(variables('guidString'),8,4),'-',substring(variables('guidString'),12,4),'-',substring(variables('guidString'),16,4),'-',substring(variables('guidString'),20,12),'')
4. Now run the flow manually, and you can see the string is converted to guid in Power Automate.
This is how to convert string to guid() in Power Automate.
How to Use GUID() in Power Automate
Here, we will see how we can generate a unique ID with a parameter in Power Automate.
List of parameters we can use with guid() in Power Automate
Parameter | Expression | Description | Result |
---|---|---|---|
guid() | generate unique id | 0c556f58-5242-4a1c-9cea-8fd39e7f36a8 | |
N | guid(‘N’) | guid in number format | 0c556f5852424a1c9cea8fd39e7f36a8 |
B | guid(‘B’) | guid with curly braces | {0c556f58-5242-4a1c-9cea-8fd39e7f36a8} |
D | guid(‘D’) | guid without left and right braces | 0c556f58-5242-4a1c-9cea-8fd39e7f36a8 |
P | guid(‘P’) | generate guid as parameter | (0c556f58-5242-4a1c-9cea-8fd39e7f36a8) |
Example 1: Using parameter ‘N’ in guid()
In Power Automate Cloud, create an Instant cloud flow that will trigger Manually.
Next, click on the +New step and select Compose action to generate a unique id without ‘-‘. Then provide the below information:
- Inputs: Provide the below expression
guid('N')
Now run the flow manually, and you can see the guid is coming as Number format without ‘-‘.
Example 2: Using parameter ‘B’ in guid()
In Power Automate Cloud, create an Instant cloud flow, that will trigger Manually.
Next, click on the +New step and select Compose action to generate a unique ID with {} braces. Then provide the below information:
- Inputs: Provide the below expression
guid('B')
Now run the flow manually, and you can see the guid is coming with {} braces.
Example 3: Using parameter ‘P’ in guid()
In Power Automate Cloud, create an Instant cloud flow that will trigger Manually.
Next, click on the +New step and select Compose action to generate a unique id with () braces. Then provide the below information:
- Inputs: Provide the below expression
guid('P')
Now run the flow manually, and you can see the guid is generated with ()braces.
Conclusion
In this Power Automate tutorial, we saw how to convert string to guid in Power Automate. I have also explained how to use GUID() in Power Automate with parameters. This is how to generate unique IDs in Power Automate.
You may like the following tutorials:
- Convert String to Date in Power Automate
- Convert String to Decimal in Power Automate
- Convert String to Object in Power Automate
- Convert a String to an Array in Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com