Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to calculate and display a new field on a grid?

Posted on by 790

I'm new to AX development.  I have created a grid control with a few fields.  One field is named Qty and another field is named ScrapQty.  I now want to add another field named Remainder.  Remainder = Qty - ScrapQty.  But I can't figure out how to do this.  Can anyone help?

*This post is locked for comments

  • Verified answer
    kmckelvey3 Profile Picture
    kmckelvey3 195 on at
    RE: How to calculate and display a new field on a grid?

    I believe your method heading should be:

    display real GetUnrecoverableScrap(wfsProdJournalRoute prodJournalRoute)

  • Robert Herrmann Profile Picture
    Robert Herrmann 790 on at
    RE: How to calculate and display a new field on a grid?

    Ok, thanks for the help.  But I get a syntax error when I try this.  Here is my code:

    display UnRecoveredScrap GetUnrecoverableScrap(wfsProdJournalRoute prodJournalRoute)

    {

         real UnRecoveredScrap = this.QtyGood - this.NGK_RecoverableScrapQty;

        Return UnRecoveredScrap;

    }

    The first line is underlined in red so I assume the syntax error is here.  What am I doing wrong?

  • Suggested answer
    PA-22040759-0 Profile Picture
    PA-22040759-0 6,194 on at
    RE: How to calculate and display a new field on a grid?

    Here a link to MSDN where these "Display" fields are explained: msdn.microsoft.com/.../aa595058.aspx

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to calculate and display a new field on a grid?

    Hi Robert,

    You would use a display method on the table which is linked to your grid.

    (search for 'display' on the AOT tables node to have a reference.

    In this method you'll have 1 line:

    return this.Qty - this.ScrapQty

    Go back to your form with the grid, add a new control of the Type Real, specify the datasource and don't specify a field, but use the method property to insert the name of your display method.

    You should have a calculated field by now.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans