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)

AX 7 post partial packing slip X++

(0) ShareShare
ReportReport
Posted on by 1,027

Hi Experts,

I am using below code to post partial purchase invoice. But the system is posting packing slip for all the lines of the PO.

Actually, I want to post packing slip only for the lines which matches below 'while select' statement.

while select purchaseLinePartial
                    where   purchaseLinePartial.PurchId == purchaseTable.PurchId
                    &&      purchaseLinePartial.XP_POLineStatus == XP_POLineStatus::Processed
                    {
                        ttsbegin;
                        purchaseLinePartial.selectForUpdate(true);
                        purchaseLinePartial.setInventReceivedNow();
                        purchaseLinePartial.update();
                        ttscommit;
                    }
                    // Post packing slip
                    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
                    purchFormLetter.update(purchaseTable,strFmt("Inv_%1", purchaseTable.PurchId,systemdateget(),PurchUpdate::ReceiveNow,
                            AccountOrder::None,false,false));

Kindly provide some input.

Thanks,

N.Sridhar

*This post is locked for comments

I have the same question (0)
  • Sridhar Narayanan Profile Picture
    1,027 on at

    Hi Parab,

    May I know what exactly I need to add in the code?

    If you mention the code snippet that would help.

    Thanks.

    N.Sridhar

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Sridhar Narayanan,

    Please refer this old thread discussing similar question community.dynamics.com/.../182415 there you can find answer on your question.

  • Verified answer
    Sridhar Narayanan Profile Picture
    1,027 on at

    Hi Sukrut & Ievgen, Thanks for your input. Below code done the trick

    while select purchaseLinePartial
                    where   purchaseLinePartial.PurchId == purchaseTable.PurchId
                    &&      purchaseLinePartial.X_POLineStatus == X_POLineStatus::Processed
                    &&      purchaseLinePartial.PurchStatus != PurchStatus::Canceled
                    {
                        purchaseLinePartial.selectForUpdate(true);
                        purchaseLinePartial.InventReceivedNow = purchaseLinePartial.PurchQty;
                        purchaseLinePartial.PurchReceivedNow = purchaseLinePartial.PurchQty;
                        purchaseLinePartial.update();
                    }
    
                    query = new Query(queryStr(PurchUpdate));//Query for the filter criteria
                    query.dataSourceTable(tableNum(PurchTable)).addRange(fieldnum(PurchTable,PurchId)).value(queryValue(purchaseTable.PurchId));
                    query.dataSourceTable(tableNum(PurchLine)).addRange(fieldNum(PurchLine,X_POLineStatus)).value(queryValue(X_POLineStatus::Processed));
                    query.dataSourceTable(tableNum(PurchLine)).addRange(fieldNum(PurchLine,PurchStatus)).value(queryValue(PurchStatus::Backorder));
                    chooseLinesQuery = new SysQueryRun(query);
                    purchFormLetter = PurchFormLetter_PackingSlip::newPackingSlipFromChooseLineQuery(chooseLinesQuery,purchaseTable);
      
                    ttsbegin;
                    purchFormLetter.chooseLinesQuery(chooseLinesQuery);
                    purchFormLetter.update( purchaseTable,productReceiptId,systemDateGet(),PurchUpdate::ReceiveNow,AccountOrder::None,false,false);
                    ttscommit;
    
                    ttsbegin;
                    try
                    {
                        purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
                        purchFormLetter.update(purchaseTable,productReceiptId,systemdateget(),PurchUpdate::PackingSlip);
                    }
                    catch(Exception::Error)
                    {
                        throw Exception::Error;
                    }
                    ttscommit;


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
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans