Converting Code that starts with multiple zeros to Integer

JamieBrownJamieBrown Member Posts: 107
Hi,

I'm sure theres a simple answer, but this is driving me mad. Do any of you know how to stop zeros from being omitted that prefix a code variable when using Evaluate to convert to an Integer?

Thanks in advance.

Comments

  • garakgarak Member Posts: 3,263
    datetype integer / decimal doesn't use to leading zeros (question how many?).
    U can only use a textfield to display it on a form or in a report.
    Do you make it right, it works too!
  • JamieBrownJamieBrown Member Posts: 107
    Hi garak,

    Potentially the code could have a maximum of 2 leading zeros..

    I'll just have to work around it if it's not possible.

    Thanks though.
  • kinekine Member Posts: 12,562
    One question: why you need that?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    JamieBrown wrote:
    Do any of you know how to stop zeros from being omitted that prefix a code variable when using Evaluate to convert to an Integer?
    What are you talking about? Integers don't have leading zeroes.
  • garakgarak Member Posts: 3,263
    As i and Danial said, decimal and integer doesn't use leading zeros.
    With how many i mean, how should the serverengine know, how many zerors it must set before the number.
    So if you need for example:

    00001
    00230
    00232
    02346
    23456
    67400

    use a code field. If you need the datatype integer for calculating and the leading zeros only for displaying u can use a textbox with sourceexpresion = MyIntAsCodeVariable and set the MyIntAsCodeVariable =
    MyIntAsCodeVariable := '0000' + format(IntegerField); //or better an algorithm if you need a defined lenght (for example lenght must be 8 -> 00000001, 00345678)
    

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.