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)

Retail Transaction and Sales Table

(1) ShareShare
ReportReport
Posted on by

I am newbie on Dynamics AX, and I need to make a report about discount code in sales order line used by customer. 

I found that the discount code can be found in RetailSalesDiscountLine and RetailTransactionDiscountLine table.

But there are no sales order number in RetailSalesDiscountLine. So how can I get the discount code by sales order line?

And are there any relationship between transaction and sales?

Thank you very much~~~~~~~~~

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Following job/code provides you relationship between salesLIne and retailSalesDiscountLine. I couldn't find table RetailTransactionDiscountLine  in my environment, so assumed it to be RetailTransactionDiscountTrans and comment it if not required. I don't have suitable data to test it, let me know if anything is missing.

    static void RetailDiscountCode(Args _args)
    {
        SalesTable              salesTable;
        SalesLine               salesLine;
        RetailSalesDiscountLine retailSalesLine;
        RetailPeriodicDiscount  retailPeriodicDiscount;
        RetailTransactionDiscountTrans retailTransactionDiscountTrans;
        
        while select salesLine
            join salesTable
            where salesTable.SalesId == salesLine.SalesId
            && salesTable.SalesId == "XYZ"
            join retailSalesLine
            where retailSalesLine.InventTransId == SalesLine.InventTransId
            join retailPeriodicDiscount
            where retailPeriodicDiscount.OfferId == retailSalesLine.PeriodicDiscountOfferId
            outer join retailTransactionDiscountTrans // Please comment this if not required
            where retailTransactionDiscountTrans.PeriodicDiscountOfferId == retailPeriodicDiscount.OfferId // comment if not required
        {
            info(strFmt("SalesId: %1, LineNum: %2, ItemId: %3, DiscountCode: %4", salesTable.SalesId, salesLine.LineNum, salesLine.ItemId, retailSalesLine.DiscountCode));
        }
    }


  • Suggested answer
    Community Member Profile Picture
    on at

    Thanks Chaitanya~~!

    Typo on RetailTransactionDiscountLine , it is RetailTransactionDiscountTrans~~~

    So InventTransId is the relation key between RetailSalesDiscountLine, RetailSalesLine and SalesLine table~~

    Thank you very much~~!

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    NP. Can you mark the helpful answers as verified.

  • vglu Profile Picture
    15 on at

    Hi Dan,

    Relation between SalesLine and RetailSalesDiscountLine you can find under relation node in RetailSalesDiscountLine  table. 

    RetailSalesDiscountLine.InventTransId == SalesLine.InventTransId 

  • Community Member Profile Picture
    on at

    Thanks Vglu~~

    I found that there are some record missing in RetailSalesdiscountLine (e.g. Mix and Match), so I change it to RetailTransactionSalesTrans, RetailsTransactionTable and RetailsTransactionSalesTrans. But there are no sales order line number in this three tables.

    So how can I get the SO line number?  actually I want to find out discount code by sales order line. Thanks~~~

  • vglu Profile Picture
    15 on at

    SalesLine table has index for InventTransId field. Index not allow duplicates. This mean, if you have InventTransId - you can find SalesLine with Line number, or in different way, if you have SalesLine - you can find all discounts applied for this line. (you can get a few Discounts for one line)

  • Community Member Profile Picture
    on at

    For InventTransId field in SalesLine table, how can I get the discount code and offer ID? As I cannot get them in sales table but in RetailsTransaction table, however I cannot linkup them with any field as key. 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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans