How to Convert String to GUID in Power Automate?

    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.

    convert string to guid Power Automate

    Next, provide the flow name and select Manually trigger a flow action. Then click on Create.

    convert string to guid Microsoft Power Automate

    Now, you can see the “Manually trigger a flow” action is added to the flow page.

    Power Automate convert string to guid

    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
    How to convert string to guid Microsoft Power Automate

    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),'')
    How to convert string to guid Power Automate

    4. Now run the flow manually, and you can see the string is converted to guid in Power Automate.

    string to guid 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

    ParameterExpressionDescriptionResult
    guid()generate unique id0c556f58-5242-4a1c-9cea-8fd39e7f36a8
    Nguid(‘N’)guid in number format0c556f5852424a1c9cea8fd39e7f36a8
    Bguid(‘B’)guid with curly braces{0c556f58-5242-4a1c-9cea-8fd39e7f36a8}
    Dguid(‘D’)guid without left and right braces0c556f58-5242-4a1c-9cea-8fd39e7f36a8
    Pguid(‘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.

    Microsoft power automate string to guid()

    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')
    power automate string to guid()

    Now run the flow manually, and you can see the guid is coming as Number format without ‘-‘.

    power automate convert string to guid()

    Example 2: Using parameter ‘B’ in guid()

    In Power Automate Cloud, create an Instant cloud flow, that will trigger Manually.

    Microsoft power automate string to guid()

    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')
    string to guid in Microsoft Power Automate

    Now run the flow manually, and you can see the guid is coming with {} braces.

    string to guid in Power Automate

    Example 3: Using parameter ‘P’ in guid()

    In Power Automate Cloud, create an Instant cloud flow that will trigger Manually.

    Microsoft power automate string to guid()

    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')
    string to guid using Microsoft Power Automate

    Now run the flow manually, and you can see the guid is generated with ()braces.

    string to guid using Power Automate

    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:

    >