Skip to content

[Bug]: APIV2 LoadFields at OnAfterGetRecord leads to JIT Load Error in Telemetry #29634

@BernhardKloibmueller

Description

@BernhardKloibmueller

Describe the issue

We see on the endpoint APIV2/SalesInvoices sometimes the JIT Load error for the fields "Currency Code" or "Amount".
In comparison to the number of successfull requests they are less than a tenth of a percent.

After Looking into the page 30012 "APIV2 - Sales Invoices" I discovered that these fields are loaded with Rec.LoadFields in the trigger OnAfterGetRecord. Which I assume leads to this race condition I see in my customer's temeletry.

Rec.LoadFields("No.", "Currency Code", "Amount Including VAT", Posted, Status);

Wouldn't it be better to change this loading to reading the data immediately? So I propose to change the LoadField which is called from trigger OnAfterGetRecord to an AddLoadFields in the OnOpenPage trigger where it should be added to the visible fields and thus directly loaded. Since there is no condition why the OnAfterGetRecord is not executing the LoadField command I assume this would be better than loading the fields afterwards.

There are simular implementations other pages as well but with less fields.
page 30051 "APIV2 - Bank Accounts"
page 30038 "APIV2 - Sales Credit Memos"
page 30037 "APIV2 - Sales Quotes"
page 30042 "APIV2 - Purchase Invoices"
page 30083 "APIV2 - Purchase Credit Memos"

Expected behavior

Eliminating the JIT Load error in race conditions.

Steps to reproduce

Create a large number of sales invoice records. Write a routine to update these records with different currency codes and shuffle them in the records.

Read the data with the endpoint salesinvoices and hope to fall into the race condition gap.

Additional context

It should even be possible just to add the AddLoadFields commend because the LoadFields will not JIT load fields which are already loaded.

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions