Thursday 23 May 2019

STRMENU dialog in Dynamics NAV

Hello reader, am aware CAL is rapidly becoming old school. However, someone like you and me still find it useful. While i was working on a customization for some client, i realized the need to display a dialog selection menu similar to the one users pick while posting. This is something i had not encountered in a long time. It was time for me to check the archive to remind myself. Fortunately you wont have to check many places as am gonna show you how.
The illustration below shows the selection menu am talking about



Here is a sample code to achieve it. First some rules;

  • Identify the menu options you want to display to users i.e invoice,receive, receive and invoice
  • Identify the default option
  • Craft a descent statement to accompany the dialog

Time to implement your dialog

selection := DIALOG.STRMENU('Order,Received,Processing,Finished',1,'Please select option to update status of transaction');

IF selection = 1 THEN BEGIN
  Status := Rec.Status::Order;
  MESSAGE('Status of order %1 successfully updated to ORDER',Rec."No.");
END ELSE IF selection = 2 THEN BEGIN
  Status := Status::Received;
  MESSAGE('Status of order %1 successfully updated to RECEIVED',Rec."No.");
END ELSE IF selection = 3 THEN BEGIN
  Status := Status::Production;
  MESSAGE('Status of order %1 successfully updated to PROCESSING',Rec."No.");
END ELSE IF selection  = 4 THEN BEGIN
  Status := Status::Finished;
  MESSAGE('Status of order %1 successfully updated to FINISHED',Rec."No.");
END;

Details of the function
DIALOG.STRMENU(list of menu options, default choice represented as an integer, message to accompany dialog);
The function returns an integer

please note;
"selection" is an integer variable.
"Status" is a table field whose options include {Order,Received,Production,Finished}
The text in message() maybe declared under text variables

Cheers!