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)

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)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    HI FaizanBatra,

    Please read this:

    Description of AIF service technet.microsoft.com/.../bb496530.aspx

    Description of custom service technet.microsoft.com/.../hh509052.aspx

    Also this post https://dynamicsaxtipoftheday.com/2014/06/13/updating-your-pricing-journals-through-excel/ has an example how to get prices from 

    PriceDiscService using excel. 

  • Community Member Profile Picture
    on at

    Thanks alot, Can you help me with my main question?

  • Mea_ Profile Picture
    60,284 on at

    Can you elaborate your main question?

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

  • Community Member Profile Picture
    on at

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

    Please help me sir.

    TIA.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    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.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

  • Community Member Profile Picture
    on at

    Thanks alot for the help sir :)

    Really helpful.

    Regards,

    Faizan Batra

  • Community Member Profile Picture
    on at

    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));

    }

    }

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

    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.

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans