cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
YatinMumbai
Level: Powered On

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!



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!



View solution in original post

YatinMumbai
Level: Powered On

Re: Generate Unique string using SharePoint ID

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


Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,300)