The Power Automate Guid function can be used to generate a unique identifier for any purpose.
In this article, I’ll introduce you to the guid function and will provide a step-by-step guide on how to use the function in a Microsoft flow.
Power Automate Guid Function
Create a unique identifier string, known as a GUID, in a default format of 32 digits separated by hyphens, or in a different format of your choice, for example, “a7abb88d-99h9-4156-812h-d7a2e2b138ce”.
Syntax
guid('<format>')
Input parameters
- format (optional):: The input is a single character that represents the format of the returned GUID. The default format is “D”, but it can also be “N”, “B”, “P”, or “X”.
Return value
- Returns a string representation of a universally unique identifier (GUID).
Power Automate Guid Expression Example
guid()
=> "63d5594d-00e3-4ea9-8dfd-e643a128477e"
See examples of all formats below:
format | guid expression | example result |
---|---|---|
D | guid(‘D’) | e1213c00-35db-4c9a-8983-4c39501716e2 |
N | guid(‘N’) | 35e36a2eeab84fd4b816494a401ac0ec |
B | guid(‘B’) | {49e90ac9-2731-4f55-a50d-ca1af6645d4f} |
P | guid(‘P’) | (04c81d7e-7394-4896-9508-569d38922271) |
X | guid(‘X’) | {0x62324e9c,0x93cc,0x4daf,{0xa3,0xc3,0x85,0x6f,0x4c,0xa9,0xfe,0x01}} |
How To Use The Power Automate Guid Function
Follow the steps to use the Power Automate Guid function in a flow.
-
Create a new flow with trigger ‘Manually trigger a flow’
New flow
-
Add a new step by clicking on ‘+ New step’
Add a new step
-
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
-
Setup Initialize variable: 1) Provide a name ‘guids’ for example, 2) select type Array
Setup array variable guids
-
Add a new initialize variable step and 1) set name to ‘formats’, 2) set type to Array 3) set value to ‘[“D”, “N”, “B”, “P”, “X”]’
Setup variable formats
-
Add a new step by searching for ‘apply to each’ and clicking on ‘Apply to each’
Add an Apply to each step
-
Setup ‘Apply to each’ by clicking into the text field, popup opens, click on formats in the popup
Setup Apply to each
-
Add a step within Apply to each by clicking on ‘Add an action’
Add an action in Apply to each
-
Search for ‘append to array’ and click on ‘Append to array variable’
Add an Append to array variable action
-
Setup Append to array variable 1) select Name ‘guids’ and 2) click into Value text field (popup appears) 3) click on Expression, 4) set expression to ‘guid(item())’ 5) Click on ‘Update’
Setup Append to array variable
-
Save and do a test run
Result test run – Power Automate Guid function example