What's the point of SetTableView

samantha73samantha73 Member Posts: 93
edited 2022-07-07 in NAV Three Tier
Hi All
I'm trying to understand the usage of SetTableView . My understanding is that it creates a filter so the question is why we cannot just use Setrange or SetFilter instead. Below is from purchase order subform to find linked sales orders:
protected procedure OpenSpecOrderSalesOrderForm()
    var
        SalesHeader: Record "Sales Header";
        SalesOrder: Page "Sales Order";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeOpenSpecOrderSalesOrderForm(Rec, SalesHeader, SalesOrder, IsHandled);
        if IsHandled then
            exit;

        TestField("Special Order Sales No.");
        SalesHeader.SetRange("No.", "Special Order Sales No.");
        SalesOrder.SetTableView(SalesHeader);
        SalesOrder.Editable := false;
        SalesOrder.Run;
    end;

Answers

  • KTA8KTA8 Member Posts: 369
    the scope of the record it's different. When you're making a setrange of record in object 1, this filter only applies to the record in that object. When you instance object 2, that record doesn't exists. If you wanted to reply that behaviour, you will have to istance the object then put a set to the record and then on open form/page set that sets on the record.
  • ShaiHuludShaiHulud Member Posts: 228
    Your SalesOrder is a page. You cannot do "SetRange"/"SetFilter" on page, only on records. So, you filter a record (SalesHeader) and then you pass it with "SetTableView" to the page.
Sign In or Register to comment.