Clever Data Validation will automatically allow any custom tables or fields to be included in any Data Validation Templates, however developers may wish to enable uses to more easily use Data Validation Templates by adding the Validation Data action to either additional standard pages or custom pages.

This can be achieved by adding an action with a few of lines of code to the pages where the action is required. The format of the code varies slightly depending on the type of page the action is being added to:

List and Worksheet Pages

Add the following action to either a page or page extension as applicable:

action("Validate Data CDVTTMN")
{
         ApplicationArea = All;
         Caption = 'Validate Data';
         Tooltip = 'Checks the information for the selected record had been correctly completed using a data validation template.';
         Image = CheckRulesSyntax;

         trigger OnAction()
         var
                    PrimaryTable: Record <TableName>;
                    DataValidationTemplatesMgt: Codeunit "DV Templates Mgt. CDVTTMN";
                    RecRef: RecordRef;
         begin
                    CurrPage.SetSelectionFilter(PrimaryTable);
                    RecRef.GetTable(PrimaryTable);
                    DataValidationTemplatesMgt.TableValidation(RecRef);
         end;
}

Replace <TableName> with a reference to the table the list is based on.

Card Page

action("Validate Data CDVTTMN")
{
          Caption = 'Validate Data';
          Tooltip = 'Checks the information for the selected record had been correctly completed using a data validation template.';
          Image = CheckRulesSyntax;
          ApplicationArea = All;

          trigger OnAction()
          var
                DataValidationTemplatesMgt: Codeunit "DV Templates Mgt. CDVTTMN";
                RecRef: RecordRef;
          begin
                 RecRef.GetTable(Rec);
                 RecRef.SetRecFilter();
                 DataValidationTemplatesMgt.TableValidation(RecRef);
          end;
}

Document Pages

 action(ValidateDataCDVTTMN)
 {
          ApplicationArea = All;
          Caption = 'Validate Data';
          Tooltip = 'Checks the information for the selected document had been correctly completed using a data validation template.';
          Image = CheckRulesSyntax;

          trigger OnAction()
          var
                 LineRecord: Record <TableName>;
                 DataValidationTemplatesMgt: Codeunit "DV Templates Mgt. CDVTTMN";
                 RecRef: RecordRef;
                 LinesRecRef: Recordref;
           begin
                 RecRef.GetTable(Rec);
                 RecRef.SetRecFilter();
                 LineRecord.SetRange("Document Type", rec."Document Type"); //Set filters for associated line record (Document Type).
                 LineRecord.SetRange("Document No.", rec."No."); //Set filters for associated line record (Document No.).
                 LinesRecRef.GetTable(LineRecord);
                 DataValidationTemplatesMgt.DocumentValidation(RecRef, LinesRecRef);
           end;
  }

Replace <TableName> with a reference to the table that holds the associated lines that the document relates to. You may also need to adjust the filtering for the lines based on the type of document. The example above assume a standard sales or purchase document.