Message Catalog Methods
In this section, the Message Catalog methods are described in alphabetical order.
In addition to the methods listed in this topic, the following Component Interface Class methods can be used — Cancel, Create, Find, Get, Save.
Syntax
AddMessage(message_text,message_desc,message_severity)
Description
Use the AddMessage method to populate a message set with text, description, and message type. All parameters can be blank strings to create an empty message. However, it must be populated before you can save it.
The Save method must be run after AddMessage to save the message.
Parameters
Parameter |
Description |
---|---|
message_text |
Specifies the text of a message as a string value. The message length can be 100 characters or less. |
message_desc |
Specifies the description of a message as a string value. No limit on the length of the description. |
message_severity |
Specifies the type of a message as a string value. The following message types are available — Cancel, Error, Message, and Warning. The default message type is Message. If an unrecognized message type is passed in, then the message_severity parameter is set to Message. |
Returns
A number value; 0 if the specified message text is longer than 100 characters, otherwise it returns the new message number.
Example
Function AddNewMessage()
Local ApiObject &MYSESSION;
Local ApiObject &MSG_CTLG;
&MYSESSION = %Session;
&MSG_CTLG = &MYSESSION.GetCompIntfc(CompIntfc.MESSAGE_CATALOG_CI);
&MSG_CTLG.MESSAGE_SET_NBR = 31600;
&MSG_CTLG.Get();
&MYLEVEL1 = &MSG_CTLG.PSMSGCATDEFN;
Local string &msgText = "Attempted to insert duplicate rows.";
Local number &msgNumber = &MSG_CTLG.AddMessage(&msgText, "", "Error");
If &msgNumber = 0 Then
MessageBox(0, "", 0, 0, "Failed to create new message");
Return;
End-If;
End-Function;
Syntax
DeleteMessage(message_num)
Description
Use the DeleteMessage method to delete a message catalog entry.
Note: You cannot delete a message sets; only message catalog entries can be deleted.
The Save method must be run after DeleteMessage to save the changes.
Parameters
Parameter |
Description |
---|---|
message_num |
Specifies the number of a message catalog entry to be deleted as a number value. |
Returns
A Boolean value; False if the message for the given message number does not exist, True otherwise.
Example
Function Delete()
Local ApiObject &MYSESSION;
Local ApiObject &MSG_CTLG;
&MYSESSION = %Session;
&MSG_CTLG = &MYSESSION.GetCompIntfc(CompIntfc.MESSAGE_CATALOG_CI);
&MSG_CTLG.MESSAGE_SET_NBR = 31600;
&MSG_CTLG.Get();
&MYLEVEL1 = &MSG_CTLG.PSMSGCATDEFN;
If Not &MSG_CTLG.DeleteMessage(2) Then
MessageBox(0, "", 0, 0, "Invalid message number");
Return;
End-If;
End-Function;