Forum Discussion

KathyBenjamin's avatar
KathyBenjamin
Qrew Trainee
2 years ago

Adding zeros to a text field if less than 7 digits

Hi,

I have a "Control Number" field that has to be 7 digits.  I need to prefill when it is not.

See example below  I used "1" but it can be any number and I need to make it 7 digits.

1 needs to be 0000001

11  needs to be 0000011

111 needs to be 0000111

1111 needs to be 0001111

11111 needs to be 0011111

111111 needs to be 0111111

Thank you in advance.

Kathy



------------------------------
Kathy Benjamin
------------------------------
  • var text Num = PadLeft(ToText([Control Number]), 7, "0"); 

    $Num

    Above is the code to make it 7 digits. Perhaps you can use a dynamic form rule to fill a 'Final Control Number' field. But that code will change the entered number into 7 digits.

    ------------------------------
    Mike Tamoush
    ------------------------------

    • KathyBenjamin's avatar
      KathyBenjamin
      Qrew Trainee

      You made my day thank you so much!



      ------------------------------
      Kathy Benjamin
      ------------------------------