Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

partial product receipt for purchase order

Posted on by 425

hi this is my code for partial product recipt for PO

static void Job219(Args _args)
{
    PurchFormLetter   PurchFormLetter;
    PurchLine         PurchLine,PurchLineloc;
    SON_AttachmentELMOInvoice       attachmentELMOInvoice;
    str  invoiceNumber;
    PurchTable  purchTable;
    int i=0;

    purchTable = purchTable::find('00002639 ');


   PurchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);

    while select PurchLine group by DeliveryDate
       where PurchLine.PurchId == purchtable.PurchId
    {
        ttsBegin;

        while   select PurchLineloc  where PurchLineloc.DeliveryDate == PurchLine.DeliveryDate
            && PurchLineloc.PurchId == purchtable.PurchId
        {
            PurchLineloc.selectForUpdate(true);
            PurchLineloc.InventReceivedNow = PurchLineloc.PurchQty;
            PurchLineloc.PurchReceivedNow = PurchLineloc.PurchQty;
            PurchLineloc.update();

        }

        ttsCommit;

        invoiceNumber = "rdgt133fs";

       PurchFormLetter.update(purchtable,invoiceNumber,attachmentELMOInvoice.DeliveryDate,PurchUpdate::ReceiveNow);

    }

}

I  am getting an error as "

Cannot edit a record in Purchase order lines (PurchLine).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record."

 

any help what exactly i am doing wrong

*This post is locked for comments

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: partial product receipt for purchase order

    Hi Rohit,

    You can try two things here:

    - Use a direct while select forupdate instead of the call .selectForUpdate(true)

    - Call the PurchFormLetter.update() method outside the PurchLine loop.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans