Frequently used C/AL functions

It's time to learn some more of the standard functions provided by C/SIDE. We will focus on the following short list of frequently used functions: MESSAGE, ERROR, CONFIRM, and STRMENU.

There is a group of functions in C/AL called Dialog functions. The purpose of these functions is to allow communications, that is, dialog, between the system and the user. In addition, the Dialog functions can be useful for quick and simple testing/debugging. In order to make it easier for us to proceed with our next level of C/AL development work, we'll take time now to learn about those four dialog functions. None of these functions will operate if the C/AL code is running on the NAV Application Server as it has no GUI available. To handle that situation in previous versions of NAV, the Dialog function statements had to be conditioned with the GUIALLOWED function to check whether or not the code is running in a GUI allowed environment. If the code was being used in a Web Service or NAS, it would not be GUIALLOWED. However, in NAV 2017, NAS and Web Services simply ignore Dialog functions.

In each of these functions, data values can be inserted through use of a substitution string. The substitution string is the % (percent sign) character followed by numbers 1 through 10, located within a message text string. This could look like the following code snippet, assuming the local currency was defined as USD:

MESSAGE('A message + a data element to display = %1', "OrderAmount");

If the OrderAmount value was $100.53, the output from the preceding code would be as follows:

A message + a data element to display = $100.53

We can have up to 10 substitution strings in one dialog function. The use of substitution strings and their associated display values is optional. We can use any one of the dialog functions simply to display a completely predefined text message with nothing that is variable. Use of Text Constant (accessed through View | C/AL Globals in the Text Constants tab) for the message is recommended as it makes maintenance and multilanguage enabling easier.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.66.206