You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got issues with recordref with other companies in BC together with variants. How can I get this fixed ?
Working with a lot of RecordRef's and variants. Found out today that RecordRef do have CurrentCompany, but it doesn't work if the assignment to RecordRef comes from an variant and not the record itself.
Example code;
trigger OnOpenPage()
var
customer: Record Customer;
recordref: RecordRef;
variant: Variant;
begin
customer.ChangeCompany('OTHER COMP');
recordref.GetTable(customer);
Message(recordref.CurrentCompany);
clear(recordref);
variant := customer;
recordref.GetTable(variant);
Message(recordref.CurrentCompany);
end;
First message is correct company (OTHER COMP). second message will be current company and not OTHER COMP.
The text was updated successfully, but these errors were encountered:
It's not a bug. Assigning to variants happens by value, similar to passing the record to a function. State like filters and company is lost this way. So the record in the variant should have the current company.
I would suggest passing the company as a parameter or variable wherever you need it. Otherwise you can also pass a record ref.
Not really true, filters will get transferred also, but it makes sense that it will be a copy by value.
Can this however be added if it is not by design? As recordref.currentcompany do exists, and I dont like to create recordref every time I want to send an record to a generic function to do some handling. Similar like Microsoft have done with tempblob.FromRecord function.
the two messages will be the same here.
From my point I think that when the framework is copying the record (by value) to an variant it is just missing which company the record did belong to. As it just works fine with the recordref's.
Perhaps I am missing something here?
Got issues with recordref with other companies in BC together with variants. How can I get this fixed ?
Working with a lot of RecordRef's and variants. Found out today that RecordRef do have CurrentCompany, but it doesn't work if the assignment to RecordRef comes from an variant and not the record itself.
Example code;
First message is correct company (OTHER COMP). second message will be current company and not OTHER COMP.
The text was updated successfully, but these errors were encountered: