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 :
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

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans