0

Hello, I need to add a flexible amount of text (leading zeros) to a input. So f.i. input ‘666’ would become ‘0000666’ in case of a desired input of 7 characters. In case of 4 characters it would become '0666’. How to accomplish that?

asked

Ad Hermans

3 answers

4

Use

**substring($Zeros,0,$DesiredLengthValue-length($ValueWithoutLeadingZeros) )+$ValueWithoutLeadingZeros **

where:

- $ValueWithoutLeadingZeros is a string with the original value without trailing zeros

- $Zeros is a string with at least the amount of zeros for the maximum length of the value including trailing zeros (e.g. '000000000000000000000')

- $DesiredLengthValue is an integer with the Desired length of the desired value including trailing zeros

answered

Diederik Smit

-4

Hi Ad,

You could do this in an ‘On Change’ microflow or in your safe action.

use length() to check the length of the input (use toString() first if the input attribute is an Integer), and just add 0s to achieve your desired length ( if $length = 5 then '00’+$input else if length= … etc)

answered

Wieke Bouten - TimeSeries