cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SLBMetrology
Helper III
Helper III

Creating a unique ID building off of the response ID.

I'm trying to create a unique ID easily using the response ID.  I want the numbers to go up by 1 each time a new entry is added to my List.  I would like it in the format of 2021-1011, 2021-1012, etc.  

 

The way I have it set up now gives me that except when it hits  2021-1099 the next one will jump to 2021-10100 instead of 2021-1100 like I would prefer it to do.

 

Is there an easy way to make that happen by adding a simple formula within this cell??  Below is the picture of the flow I have started.

 

Thank you in advance for your help.

 

ID.gif

 

3 REPLIES 3
jinivthakkar
Super User
Super User

@SLBMetrology I think you are using SharePoint list, so I would advise you to have a list which holds your counter value.

My list

jinivthakkar_1-1612720429795.png

 

My flow

jinivthakkar_0-1612720388785.png

When your flow gets trigger, first get the counter value and use counter as required

jinivthakkar_2-1612720493423.png

Increment the counter and update the counter value 

jinivthakkar_3-1612720578717.png

 

I ran the flow, counter value after first run and keeps on increasing

jinivthakkar_4-1612720627514.png

add(int(outputs('Get_item')?['body/Title']),1) /* adds 1 to string value from Get list item action */

Keeping a track of the count and having the logic to get the current count and then update it in the flow is not the best approach.

 

Hope my idea helps.

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

tom_riha
Super User
Super User

Hello @SLBMetrology ,

I'd build the unique ID before the 'Create item' action in a variable and then use the variable instead.

  1. Intialize a string variable
  2. Add a condition to check if the 'Response Id' is less than 100
    1. If it's less than 100, store 10[Response Id] into the variable
    2. If it's more than 100, store 1[Response Id] into the variable
  3. Use the variable in the 'Create item' action: formatDateTime(...)-[variable]

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha this is good solution as long as the response ID doesn't exceed 999.

 

And we would have to keep adding the conditions every time the response changes from 999 to 1000 and then again 9999 to 10000 and so on and handling this would bring a switch case or something which will check if response ID is less than 100 or greater than 100 but less then 1000 and so so, it will keep adding it up making it more and more complex for no reason.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,509)