Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Intercompany Purchase order to Sales order - passing Data

Posted on by 687

Dear Experts,

Background: I have A company and B company, I will set up trading Relationship between vendor A com and Customer B com like this 

2016_2D00_07_2D00_14_5F00_14h37_5F00_47.png

It's mean, when I create PO in A com, it's also create SO in B com

Purpose: I did add one option (parameter)  like this in Intercompany configure form

2016_2D00_07_2D00_14_5F00_14h44_5F00_19.png

Here is SO that I opened in B com base

2016_2D00_07_2D00_14_5F00_14h41_5F00_30.png

I want this Sales origin field in SO (that created from PO) automatically come base on Parameter I put in Intercompany configure form.

Is there a possibility? then Which class that I need to take to do that ?

 Version: AX 2012 R3
thank you in advance,

 
  • Luan Nguyen Profile Picture
    Luan Nguyen 687 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Yes, Thank for your commend, I agree it was not best practice.

    anyways, if using this way we have to check InterCompanyOrder first then insert(),

    Base on your first reply, it's correct, but one thing I done know how to do is debugging ? I did try using Visual Studio but it did not work, I think because of AIF service. So, do you have any idea about this?

    Thanks

  • krishna.rao@dax Profile Picture
    krishna.rao@dax 2,947 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    It's not a wise idea/best practice to write code directly in insert method of SalesTable.

    We need to follow the standard AX flow for data updation. I've worked similar requirement in the past & done as said in first reply.

    I'm not aware of the code which you've written.

  • Luan Nguyen Profile Picture
    Luan Nguyen 687 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Dear Krishna,

    Thank for your reply,

    In my case, I can do it by 2 ways

    1. In axSalesTable, You can create new parm method here and passing data from Intercompany configure form, Save it in InterCompanyEndpointActionPolicy, to inter Create SO from PO.

    2. You can easy directly write in Insert() method of SalesLine or SalesTable with below relation (also save field parm in InterCompanyEndpointActionPolicy)

    party = CustTable::find(salesTable.CustAccount).Party;
    tradingPartnerCustRecId = InterCompanyTradingPartner::findCustomer(party,salesTable.dataAreaId).RecId;
    select interCompanyTradingPartner
    where interCompanyTradingPartner.RecId == tradingPartnerCustRecId;
    tradingPartnerVendRecId = InterCompanyTradingRelation::getRelatedTradingPartner(interCompanyTradingPartner).RecId;
    interPartner = InterCompanyEndpointActionPolicy::findPartner(tradingPartnerVendRecId).InterCompanyTradingPartner;
    
    salesTable.SalesOriginId = InterCompanyEndpointActionPolicy::findPartner(tradingPartnerVendRecId).SalesOriginId;
    salesTable.update();

    Correct me if any wrongs.

    Thanks

  • krishna.rao@dax Profile Picture
    krishna.rao@dax 2,947 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Dear Max,

    Could you please elaborate how you find the place for sales header creation &

    what are the changes you made. So that someone might find how to fix.

    If you observe responses which you marked as answered  are not in harmony.

  • Luan Nguyen Profile Picture
    Luan Nguyen 687 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Dear Krishna,

    Thank for your answer.
    Of course, the Debugger works properly.
    But It was not go to your method that you mentioned.
    I did find SO Line insert on SalesLineType/Insert() Class, but I couldn't find where is SO header created from PO.
    Any Ideals ?

    Thank

  • krishna.rao@dax Profile Picture
    krishna.rao@dax 2,947 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    In my system break point hitting  the method interCompanyMirror

    Ensure that you have proper debugger configurations & Module setup parameters.

    & also keep break point in insert() method of Sales Table method.Here you find how the data is filling 

    in the SalesTable

  • Luan Nguyen Profile Picture
    Luan Nguyen 687 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Hi Krishna,

    Thank for your answer!

    Actually, I already did bebug all those class (Purchtableform, PurchTableType), method on PurchTalbe form, Method on DS PurchTalbe, but no result.

    you mentioned Classes\PurchTableType\interCompanyMirror, I put breakpoints here but it not go inside.

    Any helps?

    Thanks

  • Verified answer
    krishna.rao@dax Profile Picture
    krishna.rao@dax 2,947 on at
    RE: Intercompany Purchase order to Sales order - passing Data

    Place a breakpoint in insert() method of Sales Table & find how the data filled up.

    Probably need to place your customized code here

    Classes\PurchTableType\interCompanyMirror

    // to this 

    if (create || purchTable.fieldChanged(fieldnum(PurchTable, DeliveryPostalAddress)))
    {
    axSalesTable.parmDeliveryPostalAddress(purchTable.DeliveryPostalAddress);
    }

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans