web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Custom page check if Purchase Order exists before advancing

(1) ShareShare
ReportReport
Posted on by 374
Hello!
 
I have a customer that wanted to choose the Purchase Order number themselves when generating a Purchase Order from a Sales Order. I have made the logic that adds the custom Purchase Order number the user inputs, but I need a check in the dialog box.
 
I made a page with a single input:
 
 
When the user writes in their preferred number, I need to check if there is already a Purchase Order existing with that number. If that is the case, the user needs to insert another number. How can I disallow them from advancing from this page if the system finds an existing record?
 
Here is the code to the Page:
 
page 50103 "No Input"
{
    PageType = StandardDialog;
 
    layout
    {
        area(Content)
        {
            field("Purchase Order No."; TempNo)
            {
                ApplicationArea = All;
            }
        }
    }
 
    var
        TempNo: Code[20];
 
    procedure ExitManualNo(): Code[20];
    begin
        exit(TempNo);
    end;
}
 
And this is the code to the codeunit I am using:
 
codeunit 50100 "MyCodeUnit"
{
    SingleInstance = true;
   
    [EventSubscriber(ObjectType::Page, Page::"Sales Order", 'OnBeforeActionEvent', 'CreatePurchaseOrder', false, false)]
    local procedure MyProcedure(var Rec: Record "Sales Header")
    begin
    Clear(InputPage);
        InputPage.LookupMode(true);
        if InputPage.RunModal() = Action::LookupOK then begin
            SalesOrder := Rec;
            UserInputManualNo := InputPage.ExitManualNo();
        end;
    end;
 
    var
        UserInputManualNo: Code[20];
        SalesOrder: Record "Sales Header";
 
        InputPage: page "No Input";
}
 
 
 
 
I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,021 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,083 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 731 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans