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)

filter out the first record in table

(0) ShareShare
ReportReport
Posted on by

AX-final-upload.JPG

Hi, 

how to write a X++ job to get the first value for a unique name. ?

ie for frank i need to get 1 and for sam i need to get 2 as output

*This post is locked for comments

I have the same question (0)
  • Munib Profile Picture
    2,500 on at

    Hi,

    There is extensive documentation on select queries. Here is one to look at.

    https://msdn.microsoft.com/en-us/library/aa848113.aspx

  • Suggested answer
    Ajit Profile Picture
    8,788 on at

    What do you mean by first value? the one which you have created first? You can think of using keyword firstonly and also order by recid. But first clear the requirement here.

  • Verified answer
    YY Lim Profile Picture
    960 on at

    answer.png

    I think you mean this.

    static void Job48(Args _args)
    {
        Table33 tableGroup,table33;

        ;

        while select tableGroup
        group by Name
        {
            select firstOnly table33
            order by table33.RecId
            where table33.Name == tableGroup.Name;

            info(strFmt("%1",table33.Number));
        }
    }

  • Verified answer
    RamKumarb Profile Picture
    828 on at

    Hi ,

     try this code

    static void Job212(Args _args)

    {

       Table33 table1,table2;

    while select Name from table1 group by  table1.Name

       {

           select firstOnly number from table2

               where table2.Name == table1.Name;

      info(strfmt('%1-%2',table1.Name,table2.Number));

       }

    }

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
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans