AddMessage

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;