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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,555)