web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Form Field : Integer type field, need to show zero but keep missing.

(0) ShareShare
ReportReport
Posted on by

Hey expert,


I have this integer fields.

g0g09090.png

Every time, i add 0050 and 0080, it keeps showing 50 and 80, i know it's because it's integer data type. But i need this to show zero in front of the number inputted. I can't change it to string. Any idea how to do it?

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at

    one most communly used way is to use EditDisplay method

  • Suggested answer
    Hariharans87 Profile Picture
    36 on at

    If It is only for display purpose then, you can use display method else you can use edit method.

    For display method e.g.

    display str FormattedTestNo()

    {

       return strRFix(int2str(Form_DS.TestNo), 4, '0');

    }

    Result: if the value is 50, you will get 0050

  • Hariharans87 Profile Picture
    36 on at

    Sorry, I did a mistake in the example part.

    display str FormattedTestNo(Hari_Test Form_DS)

    {

      return strRFix(int2str(Form_DS.TestNo), 4, '0');

    }

    We should pass the form datasource if we use display method in the form.

  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at

    "Every time, i add 0050 and 0080" depicts that he/she want to use it for data entry, so display method will be worthless

  • Dauvis Profile Picture
    170 on at

    An edit method is the probably the best way to do this.  The drawback on that will be that the field will not be available for filtering.

  • Hariharans87 Profile Picture
    36 on at

    Yes. You can't filter and sort the edit and display method's data. If you want filter method, you should go for string field.

  • Community Member Profile Picture
    on at

    Hi Hari, thanks for your code example.

    From your's example here's my code :

    display str FormattedNoFrom(DDSetupDDDetail _DDSetupDDDetail)

    {

     return strRFix(int2str(_DDSetupDDDetail.SetupTaxNoFrom), 4, '0');

    }

    I create this method on form/datasource/tablename's method.

    Now i should assign it to dataMethod of control property right? But when i do so, the field suddenly cannot be edited and always showing this number 3145776

  • Community Member Profile Picture
    on at

    Hi Sohaib, can you give me example code like Hari did earlier, about edit method?

    I'm planning to create it in form/Datasource's method. Thanks.

    I need example code of editmethod.

  • Hariharans87 Profile Picture
    36 on at

    Please use the below code for edit method and make sure your field maximum length is 4. If it is not 4 then, please mention the maximum length number strRFix function.

    edit str editFormattedNoFrom(boolean set, DDSetupDDDetail _DDSetupDDDetail, str enteredNo)
    {
        int taxNo;
        if(Set)
        {
            taxNo = str2int(enteredNo);
            _DDSetupDDDetail.SetupTaxNoFrom = taxNo;
        }
        else
        {
            taxNo = _DDSetupDDDetail.SetupTaxNoFrom;
        }
    
        return strRFix(int2str(taxNo), 4, '0');
    }


  • Community Member Profile Picture
    on at

    Hi, i keep getting error on this, operand not compatible

    edit SetupTaxNoFrom formattedNoFrom(                 ->my EDT with type int not string

           boolean _set,

           SetupVATDetail _SetupVATDetail,                      ->my datasourcename in form

           SetupTaxNoFrom _SetupTaxNoFrom)                ->my EDT again right

    {

       return strRFix(int2str(_SetupVATDetail.SetupTaxNoFrom), 4, '0');      ->return string??

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans