How to Generate a GUID in Power Automate

Do you need to create GUIDs in Power Automate?

Generating a globally unique identifier (GUID) in Power Automate is an essential skill for those looking to create unique IDs for records in databases, custom identifiers in applications, or as a reference to specific instances of a Flow.

Power Automate allows you to effortlessly create and integrate GUIDs into your flows through its built-in functions.

This post is going to show you how to incorporate GUID generation into your flows.

What is a GUID?

A GUID (Globally Unique Identifier) is a random sequence of 32 hexadecimal characters that can be used for identification purposes in various systems and applications.

e26ba882-1e2d-47fd-b694-8d5b29b9c9d6

They are typically formatted in groups of 8, 4, 4, 4, and 12 characters with each group separated by a dash character such as in the above example.

The chances of randomly generating the same GUID more than once are so small, they are effectively considered to be globally unique.

When working with Power Automate, you may need to create GUIDs to uniquely identify items such as records, files, or database entries to ensure the ID you create is unique.

Syntax of the GUID Function in Power Automate

Using the guid() function in Power Automate will ensure that you generate distinct GUIDs, thereby minimizing the possibility of conflicts in your dataset.

To generate a GUID, you simply need to call the guid function in your flow. It doesn’t require any parameters and returns a string formatted as 32 digits separated by hyphens.

guid()

The above function call will return a GUID like 951bdb6b-847e-4e93-9aa2-9739e858d638.

📝 Note: Each time you run the function, a new GUID will be generated.

To avoid accidental misusage of GUIDs, it’s crucial to store the generated value somewhere, such as in a variable or a compose action. This way, you can easily reference it later in your flow as needed.

Using the guid function in Power Automate is an efficient method to create unique identifiers for various use cases.

Generate a GUID in Power Automate

In this section, you will learn how to generate a GUID using Power Automate functions.

The example will show you how to create the guid expression function in the input field of a compose action. But you can use this inside any input field of any action.

The Compose action in Power Automate allows you to store and use values throughout your flow, so it is perfect for generating and storing a single GUID in your flow.

Follow these steps to create a GUID in your input field.

  1. Click into the Input field where you want to create the GUID. This will open the Dynamic content and Expression popup.
  2. Click on the Expression tab. This will display the formula editor where you can add the guide expression.
  3. Add the guid() formula to the formula bar.
  4. Press the OK button to save your expression in the input field.

Your field will now have an expression block, and when the flow runs this will generate a unique GUID.

Common Use Cases for GUIDs in Power Automate

This section will explore a couple of common use cases for generating GUIDs within Power Automate flows. Knowing when and how to utilize GUIDs effectively can be helpful for various situations, providing unique identifiers or automating file-naming processes.

Unique Identifier for SharePoint List Items

One common use case for GUIDs in Power Automate is assigning a unique identifier to SharePoint items.

When creating SharePoint list items, it’s often necessary to have a distinct identifier for each item before they have been added to the online list to prevent duplicates.

By using the guid() function in Power Automate, you can generate a unique GUID for each list item.

This provides a reliable way to avoid duplicate records and easily reference SharePoint items using their unique identifiers.

Automated Unique Filename Generation

Another popular use case for GUIDs in Power Automate is automating the generation of unique filenames for uploaded or generated files.

This can be especially helpful for situations where you want to avoid file-name conflicts or need to store many files with a similar naming structure.

To create a unique and automated file-naming system, you can incorporate the guid() function into your flow file naming by concatenating the resulting GUID with your desired file extension, such as pdf, docx, or xlsx.

Concat('Quote ', guid(), '.pdf')

For example, you could create a filename using the above expression.

The above expression would generate a filename such as Quote e362d12c-e73c-4811-9d07-5a100453d4f0.pdf with a unique GUID followed by the pdf extension.

By utilizing the guid() function in this manner, you can ensure that each generated filename is distinct and avoids potential naming conflicts.

GUIDs provide a valuable tool within Power Automate for scenarios like unique SharePoint item identification and automated filename generation.

Conclusions

Utilizing the guid() function allows you to create unique identifiers for any purpose within your workflow. This is particularly useful when you need to assign unique IDs to records, files, or other elements in your processes.

The guid() function is straightforward to use and by incorporating it into your flow you can generate a unique GUID each time the flow runs.

What have you been using GUIDs for in your flows? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!