0

Leading zero's in a number field

I am trying to format an invoice number field to have leading zero's with the following lines:

format('Invoice #', "0000");
let i := number(max((select Invoices).'Invoice #'));
'Invoice #' := i + 2

Can anyone tell me where I am going wrong?

5 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    I think you have to format the number in the last line:

    let i := number(max((select Invoices).'Invoice #'));
    'Invoice #' := format(i + 2,"0000")

    Steven.

    • paulfurness73
    • 4 yrs ago
    • Reported - view

    Thanks Steven,

    unfortunately no leading zero's is the result :(

    • Sean
    • 4 yrs ago
    • Reported - view

    Try using lpad() or change the "format mask" so it is 4 digits longer than the number of digits in your Invoice #.

    • paulfurness73
    • 4 yrs ago
    • Reported - view

    Thanks Sean, it turns out you have to have a text field for it to work.

    • PAGE
    • Bill_Page
    • 3 yrs ago
    • Reported - view

    On this note, does anyone know how to add a suffix to the number. 

    I have a number field called Customer ID. In creation, trigger = 

    let t:=this;
    let maxId := max((select 'Customer Data'). 'Customer ID');
    t.'Customer ID' := maxId+1

    But I want the number to display as: GP-001, GP-002 etc., and not just 1, 2, 3 etc.

    Thanks in advance 

Content aside

  • 3 yrs agoLast active
  • 5Replies
  • 1559Views