Sometimes you don't want to use an entire form to get user input. Dialog boxes are not a substitute for forms, but they work just fine for quick input.
Create a new codeunit from Object Designer.
Add the following global variables:
Name
Type
Subtype
Length
Customer
Record
Customer
CustomerNo
Code
20
Window
Dialog
Add the following code to the
OnRun
trigger of the codeunit:Window.OPEN('Customer No: #1####################'); Window.INPUT(1, CustomerNo); Window.CLOSE; IF Customer.GET(CustomerNo) THEN MESSAGE('Customer Name: %1', Customer.Name) ELSE MESSAGE('No customer found!);
Save and close the codeunit.
The first line of code opens an input dialog window that looks like one shown in the following screenshot:
The next line lets the user input a value and stores it in the CustomerNo
variable. The dialog window then closes and the result can be used later in code.