ReportErrorModified method: AdsValidationBase class

Syntax

ReportErrorModified(&recReportKey, &recReportError)

Description

Invoke the ReportErrorModified method to write validation errors to the database to be reviewed later on the Validation page.

Invocation of the ReportErrorModified method is optional and can be skipped if error reporting in the validation report is not a requirement for your custom validation.

Important:

ReportErrorModified is a protected method and must not be extended in your custom application class.

Parameters

Parameter Description

&recReportKey

Specifies a record based on the PSCOMPOBJKEY record definition.

&recReportError

Specifies a record based on the PSCOMPOBJERR record definition.

Returns

None.

Example

Example 1

The following pseudo-code excerpt demonstrates how to invoke the ReportErrorModified method:

Local Record &recReportKey, &recReportError, &recParent;

&recReportKey = CreateRecord(Record.PSCOMPOBJKEY);
&recReportError = CreateRecord(Record.PSCOMPOBJERR);

*** error processing ***

If * error type 1 *
/* Set error record field values */
   &recReportError.PTADSVALIDTYPE.Value = "*";
   ***
   Else
   If * error type 2 *
   /* Set error record field values */
      &recReportError.PTADSVALIDTYPE.Value = "*";
      ***
   End-If;
End-If;

ReportErrorModified(&recReportKey, &recReportError);

Example 2

The PTADSDEFN:AdsValidationBase:ProcessValidationError method provides a complete example of how to invoke ReportErrorModified:

method ProcessValidationError
   /+ &RecError as Record +/
   Local number &i, &j, &k, &m, &n, &p, &q, &r, &s, &u, &nCtr, &x, &nBegin;
   Local Field &fldError;
   Local Record &recReportKey, &recReportError, &recParent;
   Local string &strPTRecName, &strPTRecValue, &strKeyColName, &strKeyColValue, &strFieldType, &strType;
   Local Rowset &rsParent;
   Local array of string &arrRecHierarchy;
   Local %metadata:RecordDefn:RecordDefn_Manager &mgr = create %metadata:RecordDefn:RecordDefn_Manager();
   Local %metadata:Key &key;
   Local %metadata:RecordDefn:RecordDefn &defn;
   Local string &strTableName;
   &arrRecHierarchy = CreateArrayRept("", 0);
   &recReportKey = CreateRecord(Record.PSCOMPOBJKEY);
   &recReportError = CreateRecord(Record.PSCOMPOBJERR);
   &i = 1;
   &r = Value(&arrRecName [&arrRecName.Find(&RecError.Name)][2]);
   &q = 1;
   /* Logic to Populate the PTRECNAMEs and PTNUMKEYS */
   For &s = &r To 1 Step - 1
      &strPTRecName = "PTRECNAME" | String(&s);
      If &s = &r Then
         &strPTRecValue = &RecError.Name;
         &recParent = &RecError;
      Else
         &rsParent = &recParent.ParentRow.ParentRowset.ParentRowset;
         &strPTRecValue = &rsParent.DBRecordName;
         &recParent = &rsParent.GetRow(1).GetRecord(@("Record." | &strPTRecValue));
      End-If;
      &recReportKey.GetField(@("Field." | &strPTRecName)).Value = &strPTRecValue;
      &m = &arrRecName.Find(&strPTRecValue);
      &key = create %metadata:Key(Key:Class_Record, &strPTRecValue);
      &defn = &mgr.GetDefn(&key);
      &strTableName = &defn.TableName;
      &recReportKey.GetField(@("Field." | "PTTABLENAME" | String(&s))).Value = &strTableName;
      &recReportKey.GetField(@("Field." | "PTNUMKEYS" | String(&s))).Value = &arrKeyFieldNameType [&m].Len;
      &arrRecHierarchy.Push(&strPTRecValue);
   End-For;
   /* Logic to Populate the PTKEYCOLs and PTKEYTYPEs */
   For &u = &arrRecHierarchy.Len To 1 Step - 1
      &strPTRecValue = &arrRecHierarchy [&u];
      &m = &arrRecName.Find(&strPTRecValue);
      For &p = 1 To &arrKeyFieldNameType [&m].Len
         &strKeyColName = "PTKEYCOL" | String(&q);
         &strKeyColValue = &arrKeyFieldNameType [&m][&p][1];
         &strType = &arrKeyFieldNameType [&m][&p][2];
         Evaluate &strType
         When "CHAR"
            &strFieldType = "0";
            Break;
         When "LONGCHAR"
            &strFieldType = "1";
            Break;
         When "NUMBER"
            &strFieldType = "2";
            Break;
         When "SIGNEDNUMBER"
            &strFieldType = "3";
            Break;
         When "DATE"
            &strFieldType = "4";
            Break;
         When "TIME"
            &strFieldType = "5";
            Break;
         When "DATETIME"
            &strFieldType = "6";
            Break;
         When "IMAGE"
            &strFieldType = "8";
            Break;
         When "IMAGEREFERENCE"
            &strFieldType = "9";
            Break;
         End-Evaluate;
         &recReportKey.GetField(@("Field." | &strKeyColName)).Value = &strKeyColValue;
         &recReportKey.GetField(@("Field.PTKEYTYPE" | String(&q))).Value = &strFieldType;
         &q = &q + 1;
      End-For;
   End-For;
   /* Logic to Populate the PTKEYVALUEs */
   &nCtr = 0;
   For &u = &r To 1 Step - 1
      &nCtr = &nCtr + &recReportKey.GetField(@("Field.PTNUMKEYS" | String(&u))).Value;
   End-For;
   For &x = &r To 1 Step - 1
      &nBegin = &nCtr - (&recReportKey.GetField(@("Field.PTNUMKEYS" | String(&x))).Value) + 1;
      If &x = &r Then
         &recParent = &RecError;
      Else
         &rsParent = &recParent.ParentRow.ParentRowset.ParentRowset;
         &recParent = &rsParent.GetRow(1).GetRecord(@("Record." | &rsParent.DBRecordName));
      End-If;
      For &j = 1 To &recReportKey.GetField(@("Field.PTNUMKEYS" | String(&x))).Value
         If &x = &r Then
            &recReportKey.GetField(@("Field.PTKEYVALUE" | String(&nBegin))).Value = &RecError.GetField(@("Field." | &recReportKey.GetField(@("Field.PTKEYCOL" | String(&nBegin))).Value)).Value;
         Else
            &recReportKey.GetField(@("Field.PTKEYVALUE" | String(&nBegin))).Value = &recParent.GetField(@("Field." | &recReportKey.GetField(@("Field.PTKEYCOL" | String(&nBegin))).Value)).Value;
         End-If;
         &nBegin = &nBegin + 1;
         &nCtr = &nCtr - 1;
      End-For;
   End-For;
   /* Logic to actually populate the PSPRJVALIDERR main fields and then insert into the table */
   For &k = 1 To &RecError.FieldCount
      &fldError = &RecError.GetField(&k);
      If &fldError.EditError And
            &arrFieldNamesOfDynamicPrompts.Find(&fldError.Name) = 0 Then
         &recReportError.PTADSVALIDTYPE.Value = " ";
         &recReportError.PTPARAMETERVAL1.Value = " ";
         &recReportError.PTPARAMETERVAL2.Value = " ";
         &recReportError.PTPARAMETERVAL3.Value = " ";
         &recReportError.PTPARAMETERVAL4.Value = " ";
         &recReportError.MESSAGE_SET_NBR.Value = 0;
         &recReportError.MESSAGE_NBR.Value = 0;
         &recReportError.MESSAGE_TEXT_254.Value = " ";
         &recReportError.MESSAGE_TEXT_LONG.Value = " ";
         &recReportError.MSG_SEVERITY.Value = " ";
         If &fldError.IsEditTable Then
            &recReportError.PTADSVALIDTYPE.Value = "S";
            &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
            &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
            &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
            &recReportError.PTPARAMETERVAL4.Value = &fldError.PromptTableName;
            &recReportError.MESSAGE_SET_NBR.Value = "257";
            &recReportError.MESSAGE_NBR.Value = "501";
            &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 501, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name, &fldError.PromptTableName);
            &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 501, "Message Not Found");
            &recReportError.MSG_SEVERITY.Value = "E";
            &bValidationError = True;
         Else
            If &fldError.IsEditXlat Then
               &recReportError.PTADSVALIDTYPE.Value = "X";
               &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
               &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
               &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
               &recReportError.MESSAGE_SET_NBR.Value = "257";
               &recReportError.MESSAGE_NBR.Value = "503";
               &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 503, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name);
               &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 503, "Message Not Found");
               &recReportError.MSG_SEVERITY.Value = "E";
               &bValidationError = True;
            Else
               If &fldError.IsYesNo Then
                  &recReportError.PTADSVALIDTYPE.Value = "Y";
                  &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
                  &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
                  &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
                  &recReportError.MESSAGE_SET_NBR.Value = "257";
                  &recReportError.MESSAGE_NBR.Value = "504";
                  &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 504, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name);
                  &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 504, "Message Not Found");
                  &recReportError.MSG_SEVERITY.Value = "E";
                  &bValidationError = True;
               Else
                  If &fldError.IsRequired Then
                     &recReportError.PTADSVALIDTYPE.Value = "R";
                     &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
                     &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
                     &recReportError.MESSAGE_SET_NBR.Value = "257";
                     &recReportError.MESSAGE_NBR.Value = "502";
                     &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 502, "Message Not Found", &fldError.Name, &RecError.Name);
                     &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 502, "Message Not Found");
                     &recReportError.MSG_SEVERITY.Value = "E";
                     &bValidationError = True;
                  Else
                  End-If;
               End-If;
            End-If;
         End-If;
         %This.ReportErrorModified(&recReportKey, &recReportError);
      End-If;
   End-For;
end-method;