Zum Inhalt springen
Business Central performance tips from BC TechDays

Performance Giveaways

Daniel Gorski
Daniel Gorski 19. September 2022
2 Min. Lesezeit

All credits belong to Waldo. His session on BC Tech Days 2022 was refreshing and informative.

You should check his new Business Central Performance Tool:

https://github.com/waldo1001/waldo.BCPerfTool

If you want to read more about that cool guy, just check his blog
https://www.waldo.be/


Our TOP 5 "Performance"-Giveaways:


1. Check if record is filled before you fire "DeleteAll":

AssemblyCommentLine.SetCurrentKey("Document Type", "Document No.");
AssemblyCommentLine.SetRange("Document Type", "Document Type");
AssemblyCommentLine.SetRange("Document No.", "No.");
if not AssemblyCommentLine.IsEmpty() then
    AssemblyCommentLine.DeleteAll();

2. Don't load the whole record. Load always a subset by using "SetLoadFields":

Item.SetLoadFields(Item."Item Category Id", Item."Item Category Code");
Item.SetRange(Item."Item Category Code", '');
if Item.FindSet() then
    repeat
        Item2 := Item;
        if ItemCategory.GetBySystemId(Item2."Item Category Id") then begin
            Item2."Item Category Code" := ItemCategory."Code";
            Item2.Modify();
        end;
    until Item.Next() = 0;

3. Calculating flowfields always outside the loop by using SetAutoCalcFields:

ConfigPackageTable.SetAutoCalcFields("Table Name");
if ConfigPackageTable.FindSet() then
    repeat
        if not HideDialog then
            ConfigProgressBar.Update(ConfigPackageTable."Table Name");

        ExportConfigTableToXML(ConfigPackageTable, PackageXML);
    until ConfigPackageTable.Next() = 0;

4. Using the right keys in your tables and using IncludedFields and SumIndexFields

key(Key1; "Vendor No.", "Posting Date")
{
    IncludedFields = "Currency Code", "Amount to Apply", Open;
}

key(Key2; "Vendor No.", "Posting Date")
{
    SumIndexFields = "Purchase (LCY)";
}

5. Use TextBuilder to append substrings instead of using Text variable

procedure ReadAsTextWithSeparator(InStream: InStream; LineSeparator: Text)
var
    Tb: TextBuilder;
    Line: Text;
begin
    InStream.ReadText(Line);
    Tb.Append(Line);
    while not InStream.EOS do begin
        InStream.ReadText(Line);
        Tb.Append(LineSeparator);
        Tb.Append(Line);
    end;
end;
how-to
development
business central
performance
al code
bc techdays
optimization
E-Invoicing-Formate UBL, CII, ZUGFeRD und Factur-X im Vergleich

UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt

UBL, CII, ZUGFeRD oder Factur-X – diese E-Invoicing-Formate werden ständig verwechselt. Wir erklären den Unterschied zwischen reinen XML-Formaten und Hybridform

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: Die E-Invoicing-Formate endlich verständlich erklärt
E-Invoicing formats UBL, CII, ZUGFeRD and Factur-X compared

UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained

UBL, CII, ZUGFeRD or Factur-X – these e-invoicing formats get confused all the time. We break down the difference between pure XML formats and hybrid PDF-plus-X

Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained
Weiter lesen: UBL, CII, ZUGFeRD, Factur-X: E-Invoicing Formats Finally Explained