web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get the Trade Agreement From AX

(0) ShareShare
ReportReport
Posted on by

Hello there,

I am currently new to AX and i wanted to do tier pricing so i created a trade agreement and now I'm willing to get it using the PriceDisc Service or by creating a service, Can someone please tell me how to go about this?

Also i wanted to know what is the difference between a Document Service and a Normal Service?

Regards,

Faizan Batra

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Get the Trade Agreement From AX

    Thanks for all the help, Answers my question :)

  • Verified answer
    Sohaib Cheema Profile Picture
    47,857 User Group Leader on at
    RE: Get the Trade Agreement From AX

    we cannot use time in this table because, it is date type inside ax.

    to get all records which are activated after certain date, you can make use of FromDate of PriceDiscTable

    But, if you want to put range on creation date you can use CreatedDateTime field(if you have enabled already)

  • Community Member Profile Picture
    on at
    RE: Get the Trade Agreement From AX

    Okay so the idea is to get all the trade agreements present in place and i don't want to put a limit on them like activation period.

    But i want all the trade agreements created after a certain time (let's say 16/6/2016 2:00:34+5:00)

    So i guess that's what i have to do but I'm not sure if i'm heading towards the right direction.

    TIA.

  • Verified answer
    Sohaib Cheema Profile Picture
    47,857 User Group Leader on at
    RE: Get the Trade Agreement From AX

    Hi Faizan,

    Your job is correct (technically)

    But, it may be wrong (functionally)

     

    The reason behind is that, you are getting all records of PriceDiscTable, without consideration of Active records. E.g. an item may has two records in PriceDiscTable. One may be for 2013 and one may be for 2015.

     

    So, if you need to display prices of 2015, take only relevant record w.r.t activation.

     

    Similarly AccountRelation(field) plays a vital role in taking decision, which records should be taken from PriceDiscTable

     

    You can read few details on a blog post.

     

    This was the reason that, in my provided demo job, the code is showing you how to get active or relevant record which may be of your interest.

     

    Actually I am not sure what is your ultimate purpose overall, by getting all records of PriceDiscTable

  • Community Member Profile Picture
    on at
    RE: Get the Trade Agreement From AX

    How does this look? looks good :p

    static void Job13(Args _args)

    {

     Query query;

    QueryBuildDataSource qbds1;

       QueryBuildDataSource qbds2;

    QueryRun queryRun;

    PriceDiscTable pricedisctab;

       InventTable it;

           QueryBuildRange qbr;

        QueryBuildLink qbl;

    query = new Query();

       qbds1 = query.addDataSource(tableNum(PriceDiscTable));

       qbds2 = qbds1.addDataSource(tableNum(InventTable));

       qbl = qbds2.addLink(fieldNum(PriceDiscTable,ItemRelation),fieldNum(InventTable,ItemId));

    queryRun = new QueryRun(query);

    while (queryRun.next())

    {

       it = queryRun.get(tableNum(InventTable));

       pricedisctab = queryRun.get(tablenum(PriceDiscTable));

       info(strFmt("%1,%2,%3",it.ItemId,pricedisctab.Amount,pricedisctab.Percent1));

    }

    }

  • Community Member Profile Picture
    on at
    RE: Get the Trade Agreement From AX

    Thanks alot for the help sir :)

    Really helpful.

    Regards,

    Faizan Batra

  • Verified answer
    Sohaib Cheema Profile Picture
    47,857 User Group Leader on at
    RE: Get the Trade Agreement From AX

    Hi Faizan,

    have a look at next sample job

    static void Sample_SC_priceDisc(Args _args)
    {
        PriceDisc_Price             priceDisc_Price    = PriceDisc_Price::construct();
        PriceDisc_LineDisc          priceDisc_LineDisc = PriceDisc_LineDisc::construct();
        InventDim                   inventDim;
        AmountCur                   LineAmount;
    
        priceDisc_Price.parmModuleType( ModuleInventPurchSales::Sales);
        priceDisc_Price.parmItemId("C0001");
        priceDisc_Price.parmInventDim(InventDim);
        priceDisc_Price.parmUnitID("ea");
        priceDisc_Price.parmPriceDate(systemDateGet());
        priceDisc_Price.parmQty(1);
        priceDisc_Price.parmAccountNum("");
        priceDisc_Price.parmCurrencyCode("USD");
        priceDisc_Price.parmPriceGroupId("");
        info(strFmt('price: %1',priceDisc_Price.price()));
        info(strFmt('priceUnit: %1',priceDisc_Price.priceUnit()));
        //print priceDisc_Price.price();
        //print priceDisc_Price.priceUnit();
        //pause;
    
        priceDisc_LineDisc.parmModuleType( ModuleInventPurchSales::Sales);
        priceDisc_LineDisc.parmItemId("C0001");
        priceDisc_LineDisc.parmInventDim(inventDim);
        priceDisc_LineDisc.parmUnitID("ea");
        priceDisc_LineDisc.parmDiscDate(systemDateGet());
    
        priceDisc_LineDisc.parmQty(5);
        priceDisc_LineDisc.parmAccountNum("");
        priceDisc_LineDisc.parmCurrencyCode("USD");
        priceDisc_LineDisc.parmAccountLineDiscCode();
        priceDisc_LineDisc.parmItemLineDiscCode(InventTableModule::find("C0001", ModuleInventPurchSales::Sales).LineDisc);
        //  priceDisc_LineDisc.parmSalesPurchLine(_salesPurchLine);
        priceDisc_LineDisc.findLineDiscAgreement();
        info(strFmt('discAmount %1',priceDisc_LineDisc.discAmount()));
        info(strFmt('discPct %1',priceDisc_LineDisc.discPct()));
        //print priceDisc_LineDisc.discAmount();   //linedisc
        //print priceDisc_LineDisc.discPct(); //LinePercent
        //pause;
    
        LineAmount = PriceDisc::price2Amount(priceDisc_Price.price(),
        priceDisc_Price.priceUnit(), //1
        PriceDisc::discAmount(SalesParameters::find().Disc, priceDisc_LineDisc.discAmount(), 0),//should call this,
        1,                   // deliver now
        1,
        0,
        PriceDisc::discPercent(SalesParameters::find().Disc, priceDisc_LineDisc.discPct(), 0),
        "USD",
        0,
        true);
        info(strFmt('LineAmount: %1',LineAmount));
        //print LineAmount;
        //pause;
    }

    Also, we recommend you to have a look at following path of AOT

    AOT\Data Dictionary\Tables\InventTable\Methods\salesPriceAgreement

  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    RE: Get the Trade Agreement From AX
    PriceDiscTable priceDiscTable;
    
    while select priceDiscTable
    {
     /// do stuff
    }

    Did you check link from my previous post, there is an example how to export it to excel if you need.

  • Community Member Profile Picture
    on at
    RE: Get the Trade Agreement From AX

    I want to write a job to get the lines from the trade agreement using the priceDiscTable?

    Please help me sir.

    TIA.

  • Mea_ Profile Picture
    60,284 on at
    RE: Get the Trade Agreement From AX

    Can you elaborate your main question?

    Do you want to get prices from AX using 3rd party application or something else?

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans