GUID stands for Global Unique IDentifier, and it’s a market standard that is represented by “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx “. Alternatively, since the structure is always the same, you can represent it without the hyphens, like “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” It’s a strange structure, but you can read more here if you want to understand what each section means. The GUID function helps us in two ways. First, we can try to convert a string to a GUID object or generate a new GUID.

Let’s explore it a bit more.

Usage

It follows a simple pattern.

  1. String (optional)

Example:

GUID('66a7dc02-d9c7-4c2d-812a-383fe8cf3748')

will return an object with

'66a7dc02-d9c7-4c2d-812a-383fe8cf3748'

Notice that, although they look the same, they are different objects, meaning that they react differently depending on what you do with them.

Now let’s call the GUID function without any parameter.

GUID()

will return an object with

'123e4567-e89b-12d3-a456-426655440000'

A new GUID is generated.

If you use the GUID object in a string context you don’t to convert the GUID to string. It will be converted for you with the hyphens.

The question now is, why use it? There are a lot of places where you want to have a unique identifier for a record. Although Power App does a great job to abstract this from the UI, you may need to create one if:

  1. You deal with the CDS (Microsoft’s common data services), and you need to generate the keys
  2. Deal with databases in general. Some require that you generate the ids yourself, so you may need to use the GUID function, depending on the datasource.
  3. Deal with APIs. Some APIs need you to provide GUIDs to identify objects, for example.

I understand that the usage is not frequent, but it’s important to know what they are.

Limitations

The GUID function is volatile, meaning that when used without parameters, it will return a different value each time it’s evaluated. So you’ll get a new GUID each time you call the function.

Recommendations:

Capitalisation matters

It’s important to understand that we’re talking about hexadecimal values, so the possible values are between 0 and 1 and “a” to “f”. For example:

123e4567-e89b-12d3-a456-426655440000

Microsoft typically uses the lowercase representation to avoid issues (there’s a great post in Microsoft’s Blog about this), but GUIDs are case-sensitive, meaning that the following GUIDs are different:

123e4567-e89b-12d3-a456-426655440000
123E4567-E89B-12D3-A456-426655440000
123E4567-e89b-12d3-a456-426655440000

Be very careful and define a strategy for your organization because this can generate a lot of issues if not dealt with correctly.

Don’t touch the hyphens.

Since the hyphens are optional, you don’t need to add them, so don’t try to do it. Also, if there are hyphens in the GUID object, leave them alone. The GUID function and Power Apps do a great job converting things in the background, so don’t worry about it.

Sources:

 GUID function in Power Apps 

Back to the Power Apps Function Reference

Photo by Noah Näf on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

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