cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CarlHRVA
Continued Contributor
Continued Contributor

Add custom prefix to unique ID

Hello, 

 

I am trying to create a custom ID with a text prefix before it anytime a new item is created. I have a large list that we've been using in a 2013 environment with the last ID created being 176,420.  Since I know that the 176,240 is the last ID created in our old environment, I'd like the flow to create a new unique ID( whenever a new item is submitted) in increments of one, starting with 176,241. The format of the ID would be as follows: "OTC-US-2020-176421". Any help is greatly appreciated and if any of this did not make sense please let me know and I will try to better clarify.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
DeepakS
Super User
Super User

Hi @CarlHRVA 

 

You can create an integer variable counter and initiate it with 176421.

following expression will help you creating unique ID:

concat('OTC-','US-','2020','-',variables('Counter')) 

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

View solution in original post

4 REPLIES 4
DeepakS
Super User
Super User

Hi @CarlHRVA 

 

You can create an integer variable counter and initiate it with 176421.

following expression will help you creating unique ID:

concat('OTC-','US-','2020','-',variables('Counter')) 

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

View solution in original post

CarlHRVA
Continued Contributor
Continued Contributor

Thanks for replying, @DeepakS ! When you say "initiate it with 176241", do you mean set the default value of the Variable to that? Also, I'm a bit confused how this will add 1 to the ID each new item. Should I be using an increment variable like the below or does the formula do that already somehow?

 

Here is what my variable looks like:

 

Capture.PNGCapture.PNGCapture.PNG

 

Hi @CarlHRVA 

 

Yes, set the default value to 176241.
I think I misread your question, I thought you are looping through each item, but it seems you want on item add.
For this You may need to query your list and get the total items count and add that number to 176241.

 

——————————————————
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

CarlHRVA
Continued Contributor
Continued Contributor

@DeepakS I looked closer at my list and what I needed was really close to your answer! Since I brought the list over with ShareGate the ID's still match up with items . I just needed to add the ID onto the end of the formula you provided. Thank you so much for your help!  The formula I'm using is:

 

concat('OTC-','US-','2020','-','triggerBody()?['ID']')

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (39,509)