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 :
Small and medium business | Business Central, N...
Answered

Job Queue PO Conversion with Codeunit : Get PO Numbers

(5) ShareShare
ReportReport
Posted on by 157
 
Hi All,
 
I am using a codeunit that converts all Released PQs to POs using Codeunit "Purch.-Quote to Order"
 
The codeunit works and converting released PQs to POS without issues. But I need to send an email about converted PQ numbers along with the corresponding PO Numbers 
 
after conversion is finished , i am trying to get the PO numbers . But it is not giving PO Details if more than one PQ is converted .  Kindly guide what is going wrong in the below code OR any other way to get the recently converted POs.
 
 PurchHeader.RESET();
        PurchHeader.SETRANGE("Document Type", PurchHeader."Document Type"::Quote);
        PurchHeader.SETRANGE(Status, PurchHeader.Status::Released); // Only Released quotes
 
        if PurchHeader.FINDSET() THEN BEGIN
            REPEAT
                if not First then
                    PurchNumbers += '|';
                PurchNumbers += PurchHeader."No.";
                First := FALSE;
                
                PurchQuoteToOrder.RUN(PurchHeader);
            UNTIL PurchHeader.NEXT() = 0;
 
        END;
        // Sleep(30000); // Not working
        if PurchNumbers <> '' then begin
 
            PurchHeader.RESET();
 
            PurchHeader.SETRANGE("Document Type", PurchHeader."Document Type"::Order);
 
            PurchHeader.SETRANGE("Quote No.", PurchNumbers);
 
// SEND MAIL - PO Numbers 
            if PurchHeader.FindSet() then begin //this block never executes if multiple PQs are convereted
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,748 Super User 2025 Season 2 on at
    Hi, Try the following event, I think it should be able to get all the numbers.
     
    Hope this helps.
    Thanks.
    ZHU
  • Dej Profile Picture
    157 on at
    Thank you @YUN ZHU
     
    There is a chance of converting multiple PQs to POs . I need to send a single email mentioning all POs that are converted for the last Job Queue Run.  does this event fires for every POs which will cause to send multiple PO mails ? kindly suggest
  • Gerardo Rentería García Profile Picture
    25,373 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints.

    Process sales quotes and orders with Sales Order Agent (preview) - Business Central | Microsoft Learn

    Best Regards
    Gerardo

  • Verified answer
    YUN ZHU Profile Picture
    95,748 Super User 2025 Season 2 on at
    Hi, If this is the case, I think the following event can be used. The PurchaseOrderHeader should contain all the created PO Numbers.
     
    Hope this helps.
    Thanks.
    ZHU
  • Verified answer
    Dej Profile Picture
    157 on at
    Thank you @Zhu,
     
    I'll try that. for now, i am using job queue entry onAfterModify event and get last created POs on or After Job's Start Time

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans