microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
722 stars 242 forks source link

SystemId is nullguid when using RecordRef and SystemIdNo #7648

Closed navdotnetreqs closed 5 months ago

navdotnetreqs commented 5 months ago

When trying to access the systemid-value of a record using recordreference, the field is found correctly using "SystemIdNo" but the value of the guid is always 0000000.. I even tried using LoadFields for the field but this didn't help. What's missing?

image

var
        field_i: Integer;
        SalesInvoiceHeader: Record "Sales Invoice Header";
        recordidv: RecordId;
    begin
        SalesInvoiceHeader.FindFirst();
        recordidv := SalesInvoiceHeader.RecordId;
        RecordRefe := recordidv.GetRecord();
        field_i := RecordRefe.SystemIdNo;
        fieldRefe := RecordRefe.Field(field_i);
        Message(fieldRefe.value);
sergiogp1 commented 5 months ago

This is not the right place to post that. Said that, are you debugging a new or "old" BC? Old BC can have systemId fields as 000000 because back then the system fields didn't exist, hence, records can have systemId as 00000000....

navdotnetreqs commented 5 months ago

This is not the right place to post that. Said that, are you debugging a new or "old" BC? Old BC can have systemId fields as 000000 because back then the system fields didn't exist, hence, records can have systemId as 00000000....

Hi, ok.

It's a 23. The systemid has a value when I look at the record in question, just not when accessing this way.

Seems the recref isn't loading the fields. As a workaround, doing

        RecordRefe.SetRecFilter();
        RecordRefe.FindFirst();

actually updates the value and the systemid is then found. But Loadfields does not.

Will close.