we have this formula in our MS Flow - Update Item task...
concat(items('Apply_to_each')['T_x002d_Code'] ,'-' ,items('Apply_to_each')['BoxNo'] ,'-' , items('Apply_to_each')['ID'])
but we need to add leading zeros to the BoxNo and ID so it ends up like this:
A02-00001-000235
How can we format those fields like that please?
This helped me 4 years later. I was less than thrilled with my case statement and this worked perfectly.
Thanks!
You can use format number
You can also use the formatNumber function -
concat(items('Apply_to_each')['T_x002d_Code'] ,'-' ,formatNumber(items('Apply_to_each')['BoxNo'],'00000') ,'-' , formatNumber(items('Apply_to_each')['ID'],'000000')
You can just use the "Format number" function this will return 0001 if the number 1 is inserted.
Best value!
This can also be done with a simple formatNumber() function. Use the expression
Just to clarify...
First, I need to Initialize variable with name: FormID, string value: 1
...then Set variable name: FormID, ID (for me its the SP ID)
...then when I Update item, in the my running number field I use
I got one more simple solution, only use 1 step:
Just put the Expression in the value of "Set Variable" step:
Hi, we found an even better solution, and that is to use Substring and concat...
so we create the values we need in variables using substring and concat:
so basically we simulate the Right function using LEN and SUBSTRING in several steps...
and se end up with '00024' ...
the only alternative is to use a Switch case, or follow the answer above...
HTH
Philip
stampcoin
87
Michael E. Gernaey
70
Super User 2025 Season 1
David_MA
48
Super User 2025 Season 1