Skip to main content

Notifications

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

  • Suggested answer
    GanapathyS Profile Picture
    75 on at
    RE: Show the most bought product

    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,998 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,850 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans