Dynamics Nav C/AL all message in one

I have created a page that also outputs multiple messaages. Now the question, how do I make that the messages are all output in one message. Because now it is so that I have to click away every single message to see the full page.

I have thought to save the messages somehow then at the end of all output one below the other, but I do not know how to do that. Please help

if ...
        Message('Day %1 is already present.', RecDate."Day");

and I have this several times

Why don’t you make a procedure as MyMessage, i.e. And change th call of this messages to your procedure, and in this procedure, instead of uing the Message function, you send a notificaction. This way it is not invasive and the uer do not have to push Accept with every message.

I hope this will give you a clue and is useful.

I’d probably create a variable to store the messages in then do something like:
if …
MessageText := 'Message for error goes here ';
if …
MessageText := ’ Next Message is here. ';
if len(MessageText)>0 then

That would accumulate the messages into a variable file. If I’m remember correctly how message works then then \ at the end should add a new line after each message. You’ll end up with one extra line break at the very end, but if that bothers you then you just check the length each time before adding to the string to see if it’s empty and let that decide if the \ is necessary.

On the procedure u have the errors:
Create a Temp Table variable (I usually use a temporary copy of Activity Log)
Create a temp page variable (create the object if u dont have one, and remember to use Activity Log temporary as datatable of the page, insert a repeater in the page).

Instead of saving or showing the errors, Do Inserts in the temp table.

Once u are done getting the errors and validations, show the page with all the lines with error

If there are some critical errors, u can use a formatting on the onafter trigger for the lines (page), then u can mark in red critical errors and let the warnings in a normal format.

U can stop all the code with a handler on the callback from the page.

For example, after inserting the errors in the temp table (rec); handle the errors and dont do anymore code:


if rec.count() > 0 then begin
isOK := FALSE;

If NOT isOK then showpage(rec);
else CONTINUE();

I think this is the most userfriendly and correctly solution when do u want to show a lot of errors.

Moreover u can apply the same page and table to any page u want to show errors.

This is already available.
Please look at the table 700 “Error Message” and where it is used.

One solution to this could be to create a global text variable that stores all the messages you want to display. You can concatenate each message to this variable instead of using the “Message” function. Then, at the end of your page, you can use the “Info” or “Warning” function to display all the messages in one dialog box.

Here is an example code:

// Initialize the message variable
MyMessages := ‘’;

// Check for duplicates and add message to variable
if … then begin
MyMessages += 'Day %1 is already present. '.Format(RecDate.“Day”);

// Repeat for other messages…

// Display all messages in one dialog box
if MyMessages <> ‘’ then

This way, all the messages will be concatenated into one string and displayed in a single dialog box at the end of the page. You can adjust the message type (Info, Warning, etc.) to suit your needs.