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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ax 2009 display method in grid only show first record

(0) ShareShare
ReportReport
Posted on by 1,559

Hi Friends,

I create a display method in SalesTable to display customer name. Here is code:

But, only the first record show the name in grid, if you sort it, it still show in first record but different name. Where did I miss something?

Regards,

River

display CustName custName()
{
    CustTable custTable;
    ;
    select Name from custTable where custTable.AccountNum == this.CustAccount;

    return custTable.Name;
}


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    This display method needs to be created at table level

    Please let us know where you have created the display method

  • Ganriver1 Profile Picture
    1,559 on at

    It's on SalesTable.

  • naveen singh Profile Picture
    780 on at

    Hi Ganriver,

    There is already a method exist in the salesTable name CustTable_CustAccount().Use this method to return the customer name.

    display CustName custName()

    {

           return this.CustTable_CustAccount().Name;

    }

  • Ganriver1 Profile Picture
    1,559 on at

    I used this one, it's the same thing. Just show the name for the first record in grid.

  • Suggested answer
    WPAK Profile Picture
    on at

    Hi there,

    is the display mentod created on the Table element SalesTable or on the SalesTable DataSource on the form?

    If it's created as method on the Datasource in the forum you will need to pass the buffer.

    If the method is placed on the table that isn't necessary.

    I would also advise adding the firstonly keyword. It won't change the result in this situation, but it will make sure only the first record is found and not multiple. It can only find one record in this situation, since AccountNum is unique, but no need to try and find multiple

    display CustName custName(SalesTable _salesTable)

    {

       CustTable custTable;

       ;

       select firstonly Name from custTable where custTable.AccountNum == _salesTable.CustAccount;

       return custTable.Name;

    }

  • Ganriver1 Profile Picture
    1,559 on at

    It's on the SalesTable table. Put 'firstonly' makes no difference.

    See pic. Also, the first record is blank in beginning, only when you click on it, it shows 'Name'

  • Verified answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Your display method is on SalesTable. The SalesTable data source is delayed-linked to the active sales line, therefore you simply don't have more than one SalesTable record at any time.

    If it's possible (taking into account existing logic of the form), change the delayed link to inner join. If it isn't, either add one more SalesTable datasource (this one inner-joined) or write the display method on SalesLine (but I wouldn't use the last option).

  • Ganriver1 Profile Picture
    1,559 on at

    Thanks Martin,

    That's it, it solved problem when changed to inner join.

    But, another problem is you can't sort 'Name' by clicking header.

    Is this particular for 'display method'?

  • Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Hi,

    you cannot sort on display methods or filter on them.

  • Archie Profile Picture
    457 on at

    Awesome Martin... :) This is such a simple thing, yet makes a great difference in o/p. I guess this is what it means to be an expert..Thanks. Please continue to enlighten us with your knowledge...

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans