This X++ Code Snippet post describes the use of a Message Box to ask the user for a confirmation before an update or process is executed.
X++ Code Snippet: Using a Message Box
A Message Box will be created using the Box class, asking the end user for a confirmation before the process is executed. Create following job to understand the working of the Message Box. This job will do an update of the CustTable each time the end user presses the OK button in the Message Box, else the CustTable isn’t updated.
static void tutorial_box()
{
CustTable custTable;
;
if(Box::yesNo("Modify customer?"
, DialogButton::No)
== DialogButton::No)
return;
ttsbegin;
select forUpdate custTable
where custTable.AccountNum == "1101";
custTable.Memo += "\r\n"
+ date2str(SystemDateGet(),123,2,1,2,1,4)
+ " "
+ time2str(timenow(), 1, 1);
custTable.update();
ttscommit;
}
Each time you run the Job a Message Box appears:
If the end user chooses Yes, the Memo field of the CustTable will be update, else not.
Post a Comment