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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Show the most bought product

(0) ShareShare
ReportReport
Posted on by 30

Hey! I am new in AX 2012 and I have a task to do. I need to make a code where I need to get an info with the most bought product from customers. I have to use sales orders. Can somebody help me with this code please? Thank you

I have the same question (0)
  • Suggested answer
    GanapathyS Profile Picture
    75 on at

    Hello Hogan,

    static void GS_MostSoldProduct(Args _args)
    {
    InventTable inventtable;
    InventTrans inventtrans,inventtrans1;
    real amount = 0;
    real great = 0;
    int i;
    str itemid,Name;
    while select ItemId,NameAlias from inventtable
    {
    while select * from inventtrans order by Qty where inventtrans.ItemId == inventtable.ItemId
    {
    if(inventtrans.StatusIssue == StatusIssue::Sold)
    {
    amount  = inventtrans.Qty ;
    }
    }
    if(amount)
    {
    i  = 1;
    if(great>amount)
    {
    great = amount;
    itemid = inventtable.ItemId;
    Name = inventtable.NameAlias;
    }
    }
    amount = 0;
    }
    info(strFmt("%1,%2,%3",great,itemid,Name));
    
    }

    This will give the most sold product name based on  the quantity moved out from the inventory.

    Thanks

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 738

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 453 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 286 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans