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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get purchtable and purchline details created by purchCreateFromSalesOrder.run()

(0) ShareShare
ReportReport
Posted on by

Hi Folks,
I have a code for integration using which purch orders are getting created in D365.
I am using purchCreateFromSalesOrder class for it.
The code works fine and Purch order gets created.
Now there is new req to add the notes to the purhtable and purchline from integration object, details in code below.

Henceforth wanted to check what code I need to write which will give me back the recently created purchtable and purchline from purchCreateFromSalesOrder.run

I believe if I can somehow get details of purchautocreate object created by purchCreateFromSalesOrder.run () then I can get purchtable by purchautocreate.parmPurchTable() and purchline by purchautocreate.parmPurchLine(). How do I get details of purchautocreate obj but.

class myIntClassToCreate Po
{
public void createPOFromSO(SalesTable _salesTable)
{
    TmpPurchLinePrice tmpPurchLinePrice;
    PurchCreateFromSalesOrder purchCreateFromSalesOrder
    RecordInsertList tmpPurchLinePriceList;
    tmpPurchLinePriceList = new RecordInsertList(tableNum(TmpPurchLinePrice));
    int totalLines = integrationObj.Count
    
    for (int = 0 , 1 < totalLines; i  )
    {
        intObjLine = intObjLines.get(i);
        tmpPurchLinePrice.clear();
        tmpPurchLinePrice.field1 = some val
        tmpPurchLinePrice.fieldN = some val
        if(tmpPurchLinePrice.validateWrite())
        {
            tmpPurchLinePriceList.add(tmpPurchLinePrice);
        }
    } // for end
        tmpPurchLinePriceList.insertDatabase();
        purchCreateFromSalesOrder = PurchCreateFromSalesOrder::construct();
        purchCreateFromSalesOrder.parmCallerRecord(_salesTable);
        purchCreateFromSalesOrder.parmTmpPurchLinePrice(tmpPurchLinePrice);
        purchCreateFromSalesOrder.parmSalesTable(_salesTable);
        purchCreateFromSalesOrder.tradeLineDlvType(tradeLineDlvType::None);
        purchCreateFromSalesOrder.run();
        
        // PO gets created at .run() above 
        /*I need to insert integrationObjPOHdr message at purchtable level docuref
        so how do I get details of purchtable created from .run above , so that I can pass it 
        to my custom createdocuref() which would insert/update docuref. 
        and 
        I also need to insertObjPOLine message at purchline level docuref, so how do I get 
        details of purchline created one at time so that I can validate at my end if intpurchlinemessageobj
        has value then call my docuref method to insert/update purchline docuref.*/
        
    }// method end
} // class end

Thanks

Mav

I have the same question (0)
  • Deepak Agarwal Profile Picture
    8,602 on at

    Hi Mav,

    Help me to understand the requirement. You want to add some notes on PO header and line, which can be done at the same time when you are creating it. Why you need the recently created PO details.

    Is note need to be added once its created as a separate action?

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Hi Mav,

    Can you please show us how you are creating the records in purchtable or purchline through integration? Because if you have that purchtable buffer you can easily insert/update that docuref table values.

    Thanks

    Bharani Preetham

  • Mav Profile Picture
    on at

    Thank you both for responding.

    @ Deepak Notes Once PO is created via autocreate API of which code is shared above, notes needs to be added to purchtable and purchline. Initially i wanted to create notes concurently while PO was being created but then I thought there is no point of doing that because what if PO creation fails .

    @ Bharini I do not think there is any Purchtable /purchline buffer in the purchCreateFromSalesOrder class which would return the purch id and individual purchline id's.

    Thanks

    Mav

  • Suggested answer
    Deepak Agarwal Profile Picture
    8,602 on at

    I still believe you need to add notes at the time of PO creation only, to manage fail scenarios you can try to use ttsbegin/ttscommit.

    Also, in the class purchCreateFromSalesOrder if you check method 'CheckTransferred' you can find a way to get Purchtable buffer once its created.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans