PSMessage Class Properties

This section describes the PSMessages class properties. The properties are discussed in alphabetical order.

Description

This property returns the explanation text (as a string) for the error message associated with the PSMessage object. You can use this property in conjunction with the MessageNumber property (which contains the error message number) and the MessageSetNumber property (which contains the error message set number.)

Note: ExplainText should be accessed only when necessary because it requires a second database read or application server roundtrip.

This property is read-only.

Description

This property returns the error message number (as a number) for the error message associated with the PSMessage object. You can use this property in conjunction with the MessageSetNumber property (which contains the error message set number) and the ExplainText property (which contains text explaining the error.)

This property is read-only.

Description

This property returns the error message set number (as a number) for the error message associated with the PSMessage object. You can use this property in conjunction with the MessageNumber property (which contains the error message number) and the ExplainText property (which contains text explaining the error.)

This property is read-only.

Description

This property indicates the type of the message, whether it's from the message catalog, if it's a warning, error, or information error.

This property returns a numeric value. The values are:

Value

Description

0

Message is not a message catalog entry or there is no message.

1

Message has a severity of Error.

2

Message has a severity of Warning.

3

Message has a severity of Information.

This property is read-only.

Description

This property returns a string indicating the actual field that’s in error. The syntax of the string that’s returned is as follows:

ComponentInterfaceName.[CollectionName(Row).[CollectionName(Row).[CollectionName(Row)]]].PropertyName

Image: Sample Component Interface

The following image is an example of Sample Component Interface. The string here is also returned as part of the Text property.

For example, suppose you had a Component Interface named EMPL_CHKLST_CI.

Sample Component Interface

The following indicates that the first level field, EMPLID, has the error:

EMPL_CHKLST_CI.EMPLID

The Component Interface EMPL_CHKLST_BC has a data collection (scroll) called EMPL_CHKLST_ITM. Suppose that it has 3 rows, and the STATUS_DT field was in error. The Source property would return the following string:

EMPL_CHKLST_CI.EMPL_CHKLST_ITM(3).STATUS_DT

You can use the Source property in conjunction with the MessageNumber property (which contains the error message number), the MessageSetNumber property (which contains the error message set number), the ExplainText property (which contains text explaining the error), and the Text property (which contains the text of the message.)

This property is read-only.

Example

The following example code finds the error messages and displays them to the user. It finds the field that caused the error and displays that also.

Local ApiObject &PSMESSAGE;
Local Boolean &FIND;
Local string &SOURCE, &FIELD, &TEXT;
Local number &START, &LEN, &NSTART, &FLEN;
.
.
.
For &I = 1 to &SESSION.PSMessages.Count;
   &PSMESSAGE = &SESSION.PSMessages.Item(&I);
   /* only display errors, not warnings, to user */
   If &PSMESSAGE.Type = 1 Then
      &TEXT = &PSMESSAGE.Text;
      /* find name of field in error */
      &SOURCE = &PSMESSAGE.Source;
      &LEN = Len(&SOURCE);
      /* find last dot before field */
      &FIND = False;
      &START = Find(".", &SOURCE);
      While Not (&FIND)
         &NSTART = Find(".", &SOURCE, &START + 1);
            If &NSTART = 0 Then
               &FIND = True;
            Else
               &START = &NSTART;
            End-If;
         End-While;
         &FLEN = &LEN - &START;
         &FIELD = Substring(&SOURCE, &START + 1, &FLEN);
         /* display text and field to user */
         Winmessage("You received the following error: " | &TEXT | "For field " | &FIELD);
   End-If;
End-For;

Description

This property returns the text of the message (as a string) for the error message associated with the PSMessage object. It also includes a contextual string that contains the name of the field that generated the error. The contextual string has the following syntax:

{ComponentInterfaceName.[CollectionName(Row).[CollectionName(Row).[CollectionName(Row)]]].PropertyName}

The contextual string (by itself) is available using the Source property of the PSMessage.

You can use the Text property in conjunction with the MessageNumber property (which contains the error message number), the MessageSetNumber property (which contains the error message set number), and the ExplainText property (which contains text explaining the error.)

This property is read-only.

Example

Local ApiObject &MYSESSION, &COL, &ERROR;
Local string &TEXT;
.
.
.
If &MYSESSION.ErrorPending Then 
   /* received error */
   &COLL = &MYSESSION.PSMessages;
   For &I = 1 to &COLL.Count
      &ERROR = &COLL.Item(&I);
      &TEXT = &ERROR.Text;
         /* do error processing */
      End-For;
End-if;