Page record argument does not match source table

Properties
PC0017 Warning Design Code Fix Ignore Obsolete

The AL compiler raises AL0133 for some argument type mismatches, but does not cover all page-record scenarios. When a record passed to Page.Run, Page.RunModal, or page instance methods like SetRecord and SetTableView does not match the target page’s SourceTable, the call compiles without errors but fails at runtime with a type conversion error: Argument 2: cannot convert from Record “Purchase Header” to Record “Sales Header”.

Use this optional parameter to select a specific record to display on the page. The record must be of the same type as the table that is attached to the page.

Page.RunModal(Integer [, Record] [, Any]) Method on Microsoft Learn

The same check applies to the LookupPageId and DrillDownPageId table properties. When these point to a page whose SourceTable is a different table, lookups and drill-downs fail at runtime with the same conversion error. When the target page has no SourceTable at all, a different diagnostic (PC0018 ) is raised instead.

Pass a record whose type matches the page’s SourceTable, or assign a page backed by the correct table.

Example

procedure ShowVendor()
var
    Customer: Record Customer;
begin
    Page.Run(Page::"Vendor Card", Customer); // Page record argument does not match source table [PC0017]
end;

The record variable must match the page’s SourceTable:

procedure ShowVendor()
var
    Vendor: Record Vendor;
begin
    Page.Run(Page::"Vendor Card", Vendor);
end;

The rule also flags LookupPageId and DrillDownPageId when the assigned page’s SourceTable does not match the declaring table:

tableextension 50100 "Transfer Header Ext" extends "Transfer Header"
{
    DrillDownPageId = "Production Order List"; // Page record argument does not match source table [PC0017]
}

Assign a page whose SourceTable matches the declaring table:

tableextension 50100 "Transfer Header Ext" extends "Transfer Header"
{
    DrillDownPageId = "Transfer Orders";
}

When the diagnostic is reported

  • Page.Run or Page.RunModal is called with a record whose type does not match the target page’s SourceTable.
  • A page instance method — SetRecord, GetRecord, SetSelectionFilter, or SetTableView — is called with a mismatched record type.
  • The LookupPageId or DrillDownPageId property on a table or table extension points to a page whose SourceTable is a different table.
  • The record argument is a return value from a procedure — the check is not limited to local variables.

See also