cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
YatinMumbai Advocate II
Advocate II

Generate Unique string using SharePoint ID

I have a SharePoint Document Library column called PermitNo. I need to update this on create new item with a unique string that uses SharePoint list ID . If the ID is 23, then the PermitNo should be FHD000023. Concat function will give me FHD23, no problem. I am accomplishing this with the expression -

Concat('FHD',String(variables('m_ID'))) where m_ID is avariable initiatized and set to list ID.

But I need to pad  m_ID with leading zeros. Essentially, the string should be 6 digits with leading zero.

I have seen couple of posts which use loop and they seem complicated. Is ther a function or expression that will solve this?

There should be a TEXT(ID,"000000") function in Flow to format numbers as string?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Generate Unique string using SharePoint ID

Hi @YatinMumbai ,

 

There is no  expression function for format numbers for leading zeros. Here are the steps you need to follow.

I will explain each step below.

First step is your input number (eg 23). 

Next we need to construct a Do Until Loop where the length of input number match the total digit we want which is 6 in your case.

So in your case the initial length is 2 (length of 23) so that means the loop will execute 4 times to add the leading zeros.

To add the leading zeros we will use the flow Compose step. 

Finally reassign the input number to compose output.

So it's starts with 023, 0023, 00023 and finally 000023 which is the result we want.

 

cc1.png

 

Here are my test results:

cc2.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Generate Unique string using SharePoint ID

Hi @YatinMumbai ,

 

There is no  expression function for format numbers for leading zeros. Here are the steps you need to follow.

I will explain each step below.

First step is your input number (eg 23). 

Next we need to construct a Do Until Loop where the length of input number match the total digit we want which is 6 in your case.

So in your case the initial length is 2 (length of 23) so that means the loop will execute 4 times to add the leading zeros.

To add the leading zeros we will use the flow Compose step. 

Finally reassign the input number to compose output.

So it's starts with 023, 0023, 00023 and finally 000023 which is the result we want.

 

cc1.png

 

Here are my test results:

cc2.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

YatinMumbai Advocate II
Advocate II

Re: Generate Unique string using SharePoint ID

Sounds good. Will try this out and revert with Accept as Solution.


Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (6,284)