Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Display issues with rounded decimal value in a form field

Posted on by 97

Hello everyone,

I have a real field that when user input in should only display the rounded value without any decimals even if zeroes, a simple decRound in the modified method of the field acheived that with the help of changing the NoOfDecimals to 0 and MinNoOfDecimals to 0 but the problem is that when the value is displayed; it isn't aligned properly to the right side even if alignment is set to right, when the form opens it display them as they should be but when hovering over them or selecting them; a wierd space is created which leaves the values not in the right nor centered (I only need right alignement, centered and left work fine though)
This is a screenshot of the form when opened:
field-issue-1.jpg

and this when I move the cursor over the other values and they change their location too:
field-issue-2.jpg

the code in modified of the field is (I tried here to convert value to int in an attempt to solve the issue):

public boolean modified()
{
    boolean ret;
    
    ret = super();

    ProdBOM.BOMQtySerie = real2int(decRound(ProdBOM.BOMQtySerie, 0));
    
    return ret;
}

my guess of the issue is that that space is for decimal values which are some zeroes that aren't shown since when I get NoOfDecimals to Auto and MinNoOfDecimals to Auto then I get the value followed by a comma and 3 zeroes

The field is BOMQtySerie from ProdBOM table and uses BOMQtySerie for EDT (all of these are in standard value and this is AX R2)

My next guess is trying to force these formControl value with the aid of X instead of properties but sadly I can't seem to find any documentation or help to do so
(my attempt is: 

public boolean modified()
{
    boolean ret;
    
    ret = super();

    ProdBOM.BOMQtySerie = real2int(decRound(ProdBOM.BOMQtySerie, 0));
    //ProdBOM_BOMQtySerie.alignment(0);
    //ProdBOM_BOMQtySerie.noOfDecimals(0);
    //ProdBOM_BOMQtySerie.minNoOfDecimals(0);
    
    return ret;
}

My attempt is commented since I don't know the int values correspondance of these methods and it didn't seem to change anything when I type 0 and 1 there)

Thanks in advance and hopefully I explained the issues as better as I could ^_^.

  • Fares Ben Miled Profile Picture
    Fares Ben Miled 97 on at
    RE: Display issues with rounded decimal value in a form field

    Hi Deepak and thank you for your suggestion,

    user can update the value in the form so I tried using the modified field of the table like you mentioned but I still got the same result.

    The form, the table, the field and the EDT are all standard that are used in various places so I can't change its type.

    I forgot to mentio this if it could help but the form that I am working on is ProdBOM.

    Thanks again for your thoughts and I am open to others ^_^.

  • Suggested answer
    Deepak Agarwal Profile Picture
    Deepak Agarwal 132 on at
    RE: Display issues with rounded decimal value in a form field

    Hi Ben,

    Thanks for the detailed explanation about the issue. Here is my thought.

    If you anyways need to round this field, use integer instead of real, also write your business logic in the inert method, if you are expecting the user can update this value from the front end you may consider table modified field method.

    Let me know if this helps.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans