web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Performance Question: Outstanding Purchase Orders

(1) ShareShare
ReportReport
Posted on by 8

Hi everyone,

In table 9055 “Purchase Cue”, the field Outstanding Purchase Orders is defined as a FlowField:

field(4; "Outstanding Purchase Orders"; Integer)
{
AccessByPermission = TableData "Purch. Rcpt. Header" = R;
CalcFormula = count("Purchase Header" where("Document Type" = filter(Order),
Status = filter(Released),
"Completely Received" = filter(false),
"Responsibility Center" = field("Responsibility Center Filter")));
Caption = 'Outstanding Purchase Orders';
Editable = false;
FieldClass = FlowField;
}

On page 9063 “Purchase Agent Activities”, the FlowField is also assigned in OnAfterGetRecord via CalculateCueFieldValues():

local procedure CalculateCueFieldValues()
begin
if Rec.FieldActive("Outstanding Purchase Orders") then
Rec."Outstanding Purchase Orders" := Rec.CountOrders(Rec.FieldNo("Outstanding Purchase Orders"));
end;

CountOrders() runs a query.

My questions:

  • Why does the standard assign a FlowField value explicitly if the FlowField would be calculated anyway?
  • In my tests, the code runs (verified in the debugger), but the tile shows the FlowField’s value, not the value from the code assignment.
    Does this cause double execution and extra SQL load? Is this by design for performance or caching reasons?
 
Here is my debugging example, maybe it helps you:
/// <summary>
/// The Table Extension "Sales Cue" (ID 50101) serves the purpose of extending the standard Sales Cue functionality.
/// This object is designed to add company car count information to the sales dashboard
/// for comprehensive fleet management visibility within sales activities.
/// </summary>
tableextension 50101 "Sales Cue" extends "Sales Cue"
{
    fields
    {
        field(50100; "Company Cars"; Integer)
        {
            Caption = 'Company Cars';
            FieldClass = FlowField;
            CalcFormula = count("Company Car");
            Editable = false;
            ToolTip = 'Specifies the total number of company cars in the system.';
        }
    }

    /// <summary>
    /// Counts the number of company cars in the system.
    /// </summary>
    /// <returns>17 always</returns>
    procedure CountCars(): Integer
    begin
        exit(17);
    end;
}

/// <summary>
/// The Page Extension "SO Processor Activities" (ID 50101) serves the purpose of extending the standard SO processor activities.
/// This object is designed to add company car information to the sales order processing dashboard
/// providing fleet management visibility directly within the sales order processing activities interface.
/// </summary>
pageextension 50101 "SO Processor Activities" extends "SO Processor Activities"
{
    layout
    {
        addfirst("For Release")
        {
            field("Company Cars"; Rec."Company Cars")
            {
                ApplicationArea = All;
                DrillDownPageId = "Company Car List";
                ToolTip = 'Specifies the total number of company cars in the system. Click to view the complete list of company cars.';
            }
        }
    }

    trigger OnAfterGetRecord()
    begin
        this.CalculateCueFieldValues();
    end;

    local procedure CalculateCueFieldValues()
    begin
        if Rec.FieldActive("Company Cars") then
            // Assignment to FlowField, but it won't show 17
            Rec."Company Cars" := Rec.CountCars();
    end;
}
 
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 4,220

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,958

#3
Sumit Singh Profile Picture

Sumit Singh 2,961

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans