Page SetRecord with temporary record (PC0036)

Calling SetRecord on a Page variable with a temporary record is not supported and will cause a runtime error. The Business Central runtime cannot bind a page to a temporary record instance via this method.

Example

The following code passes a temporary record to SetRecord:

codeunit 50100 MyCodeunit
{
    procedure ShowCustomer()
    var
        TempCustomer: Record Customer temporary;
        CustomerPage: Page "Customer Card";
    begin
        TempCustomer.Init();
        TempCustomer."No." := 'TEMP001';
        TempCustomer.Insert(false);
        CustomerPage.SetRecord(TempCustomer); // PC0036: Cannot use temporary record
        CustomerPage.Run();
    end;
}

Use a non-temporary record variable instead:

codeunit 50100 MyCodeunit
{
    procedure ShowCustomer(CustomerNo: Code[20])
    var
        Customer: Record Customer;
        CustomerPage: Page "Customer Card";
    begin
        Customer.Get(CustomerNo);
        CustomerPage.SetRecord(Customer);
        CustomerPage.Run();
    end;
}

Remarks

This restriction is documented in the Business Central SDK: “You cannot use a temporary record for the Record parameter.” The check applies to any record variable declared with the temporary keyword, regardless of whether the underlying table uses TableType = Temporary.