How to use MsgGet and MsgGetExplainText in a MessageBox via PeopleCode

Most often when we want to show a message we use MsgGet function in PeopleCode and use Message Catalog to substitutes the values of the parameters into the text message.

MsgGet(message_set, message_num, default_msg_txt [, paramlist])

where paramlist is an arbitrary-length list of parameters of undetermined (Any) data type to be substituted in the resulting text string, in the form:
param1 [, param2]. . .

For the message text we can pass parameters and The parameters are referenced in the message text using the % character followed by an integer corresponding to the position of the parameter in the paramlist.
But sometimes, message text is not long enough to present the required message you want, and the message text (MESSAGE_TEXT field) is limited to 100 characters.
In this case we want to use more detailed "explain text" in the Message Catalog. This can be achieved using Long Description (DESCRLONG fied in PSMSGCATDEFN record) in Message Catalog.
You can pass parameters to the long description as well. This can be useful if you want to dynamically build your message catalog in PeopleCode. Then you can use MsgGetExplainText function to retrieve the Explain text of a message from the PeopleCode Message Catalog and substitutes the values of the parameters in paramlist into the explain text. It returns the resulting message explain text as a String data type.
Now lets see how to combine these two in a message box;
MessageBox(0, "", 0, 0, MsgGet(12345, 1, "Message not found", &param1) | Char(10) | Char(13) | MsgGetExplainText(12345, 1, "Message not found", &dynamicString), 0);
  • In the above line of code Char(10) | Char(13) is used for line feed and carriage return. so that the message will show as follows,
  • You can use MsgGetText instead of MsgGet for constructing the full message.


Ayesha Wee

    Blogger Comment
    Facebook Comment


Post a Comment