cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
12strikes
Helper I
Helper I

Zero Pad ID field sharepoint list

I have a flow that will create a control number for a record, when the record is added.
The control number will be a couple of department codes, followed by the record ID zero padded to 0000. 
I'm stuck on zero padding the ID number.
If the SharePoint record id is 24, I need to zero pad it to 0024.

Thanks for your help

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Community Champion
Community Champion

Try using the Format Number action:

ekarim2020_7-1630539654666.png

which produces:

ekarim2020_1-1630539055583.png

Or you can use an expression using the formatNumber function:

 

 

formatNumber(24,'0000')

 

 

From example:

ekarim2020_8-1630539761891.png

ekarim2020_5-1630539433830.png

See: Other ways to use formatNumber


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

View solution in original post

4 REPLIES 4
ekarim2020
Community Champion
Community Champion

Try using the Format Number action:

ekarim2020_7-1630539654666.png

which produces:

ekarim2020_1-1630539055583.png

Or you can use an expression using the formatNumber function:

 

 

formatNumber(24,'0000')

 

 

From example:

ekarim2020_8-1630539761891.png

ekarim2020_5-1630539433830.png

See: Other ways to use formatNumber


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

View solution in original post

eliotcole
Power Participant
Power Participant

Hopefully this is a bit easier than attacking this with logic:

Create a (hidden, if you like) calculated column in SharePoint with that value in leading zeros.

 

Aren't you going to get problems when the list items go over 9,999? 😉

 

EDIT - I may have made a rookie mistake there, I can't remember if they got over that ID field issue where it's not available for a calculated column as the record doesn't exist yet.

 

EDIT 2 - 😅 They did not. However, if your flow is already doing other actions, then after the flow updates the list, the calculated column will have the right value in it.

 

PHEW! It still works, but it was a bit of a journey. 😏

 

This calculated column in my list (when a flow updates another part of it) will refresh with the right number after the employee ID 🙂:

=employeeNo&TEXT(ID,"0000")

 

Thanks... If we ever get to 9999, we have BIGGER problems then getting to 9999 (lol)....
I thought this would work, but it didn't.
The record is being created via a powerapp.  I created another field in my list called ID PADDED, its a calculated field with the formula =TEXT(ID,"0000")

12strikes_0-1630588477899.png

 

That works... thanks...

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!

Top Solution Authors
Top Kudoed Authors
Users online (873)