Modeless Notification Messages in Older Versions of Dynamics NAV
As we all know, it's easy to display an informational message to the user with the C/AL keyword MESSAGE. But, how many of you have encountered clients with MESSAGEs built up over time, where the user had to click through five MESSAGEs when entering a sales line, for example? MESSAGEs are cluttered, intrusive, invasive, modal and require user interaction in order to make them go away. Basically, MESSAGEs are an outdated way to make the user aware of something.
NAV 2017 introduces notifications for the Web Client, an easy, non-intrusive and non-invasive way to display a message to the client via an information bar just below the action pane. Notifications require no interaction from the user to make it go away and can even include an action, like navigate to the customer card.
Figure 1 - Modeless notifications in later versions of Dynamics NAV
ArcherPoint’s own Saurav Dhyani published a blog discussing smart notifications in NAV 2017.
Modeless Notification Messages in Dynamics NAV 2017
If you're looking for something like this to replace MESSAGE for the versions of NAV from 2009 RTC to 2016, then this blog entry is for you. The inspiration for this blog entry was the search for a modeless way of displaying an informational message to the user that requires no interaction.
I'm sure you're familiar with the Notes FactBox, present on most page objects, where users can send notifications to one another. The code shown further below will enable you to generate a new notification and have it displayed immediately (at least in my testing).
The example shown below occurred just after changing a value on the Item Card. To achieve this, a new Subscriber function was created in NAV 2016; the event to which the function subscribed was the OnAfterValidate for a custom field on the Item Card; in the function, code was written to call the custom function CreateNotification.
Figure 2 - Using a note to achieve modeless notification in versions of Dynamics NAV 2009 RTC to 2016
Dynamics NAV code to Create a new function CreateNotification
Here's how you achieve this in a custom codeunit:
PROCEDURE CreateNotification@1240060003(_Note@1240060007 : BigText;_Notify@1240060008 : Boolean;_UserID@1240060009 : Text;_RecordID@1240060012 : RecordID);
_RecordLink@1240060004 : Record 2000000068;
_RecRef@1240060011 : RecordRef;
_char1@1240060000 : Char;
_char2@1240060001 : Char;
_is@1240060003 : InStream;
_NewID@1240060005 : Integer;
_os@1240060002 : OutStream;
_TextToWrite@1240060006 : BigText;
_TextSmall@1240060013 : Text;
// AP0004 >>
// code portions courtesy Matt Traxinger - http://mibuso.com/downloads/i-love-nav-enhanced-notes-v2.01
// first, prepend the BLOB text with the length of the text
IF _Note.LENGTH <= 255 THEN BEGIN
_char1 := _Note.LENGTH;
END ELSE BEGIN
_char1 := 128 + (_Note.LENGTH - 256) MOD 128;
_char2 := 2 + (_Note.LENGTH - 256) DIV 128;
_TextToWrite.ADDTEXT(FORMAT(_char1) + FORMAT(_char2));
// second, append the actual text passed as parameter
// third, get the actual user ID passed in as parameter
IF _UserID <> '' THEN
IF COPYSTR(_UserID,STRLEN(_UserID)) = ',' THEN
_UserID := COPYSTR(_UserID,1,STRLEN(_UserID) - 1);
// fourth, generate a new Record Link rec for the RecordID passed as parameter
_NewID := _RecRef.ADDLINK(_TextSmall);
// fifth, write the text (with prepended length) to the Record Link rec
// sixth and final, set some additional fields and modify the record
_RecordLink.Type := _RecordLink.Type::Note;
_RecordLink.Notify := _Notify;
_RecordLink."To User ID" := _UserID;
_RecordLink."User ID" := LOWERCASE(_RecordLink."User ID");
// AP0004 <<
Dynamics NAV code to Call the Function
Here's the code to call the function, located in the custom EventSubscriber function:
_RecID := _RecRef.RECORDID;
Here are the variables for the above code snippet:
_Item@1240060004 : Record 27;
_bt@1240060008 : BigText;
_RecID@1240060003 : RecordID;
_RecRef@1240060005 : RecordRef;
Thanks to Matt Traxinger for his community contribution of Enhanced Notes. His code formed the basis for this modification (and saved a lot of research).
A quick Google search revealed other, similar pages referencing this topic:
For more information on Dynamics NAV 2017 features, please visit our website.
If you are interested in NAV development, check out our collection of NAV Development Blogs.
- Login Error: Communication protocol mismatch between client and server
- Creating a Date Table in Power BI
- The Top Eight KPIs Retailers Should Be Tracking (with Formulas) for Your Retail KPI Dashboard
- Difference Between IaaS, PaaS, and SaaS And When You Need to Use Them
- How to Set Custom Color Themes in Microsoft Power BI