-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to differentiate between RecordRef.Copy when using Variant #7732
Comments
This probably requires a new overload for the copy function to handle the record. There's no generic record type to cast to |
Hi, I think what you are looking for is this: var
MyTable: Record "My Table";
MyTableRecordRef: RecordRef;
MyTableRecordRef.GetTable(MyTable);
This works with both normal records and temporary records (table gets shared). Expand to see the code.table 50100 "My Table"
{
fields
{
field(1; K; Integer)
{
}
}
}
report 50100 "Test My Table"
{
UsageCategory = Tasks;
ApplicationArea = All;
ProcessingOnly = true;
trigger OnPreReport()
var
MyTable: Record "My Table";
TempMyTable: Record "My Table" temporary;
begin
GlobalLanguage(1033);
MyTable.Reset();
MyTable.DeleteAll(true);
MyTable.Init();
MyTable.K := 1;
MyTable.Insert(true);
MyTable.Init();
MyTable.K := 2;
MyTable.Insert(true);
MyTable.Mark(true);
MyTable.Init();
MyTable.K := 3;
MyTable.Insert(true);
MyTable.Mark(true);
MyTable.SetFilter(K, '>%1', 0);
MyTable.MarkedOnly(true);
TempMyTable.Init();
TempMyTable.K := -1;
TempMyTable.Insert(true);
TempMyTable.Init();
TempMyTable.K := -2;
TempMyTable.Insert(true);
TempMyTable.Mark(true);
TempMyTable.Init();
TempMyTable.K := -3;
TempMyTable.Insert(true);
TempMyTable.Mark(true);
TempMyTable.Init();
TempMyTable.K := -4;
TempMyTable.Insert(true);
TempMyTable.Mark(true);
TempMyTable.SetFilter(K, '<%1', 0);
TempMyTable.MarkedOnly(true);
Message(
'Normal: %1\\Temporary: %2',
GetRecordInfo(MyTable),
GetRecordInfo(TempMyTable));
end;
local procedure GetRecordInfo(
RecordVariant: Variant): Text
var
_RecordRef: RecordRef;
begin
_RecordRef.GetTable(RecordVariant);
exit(StrSubstNo(
'IsTemporary: %1; Count: %2; Filters: %3',
_RecordRef.IsTemporary,
_RecordRef.Count,
_RecordRef.GetFilters()));
end;
} Output:
|
Thanks for the suggestion. Since this is an improvement and not a bug, you can post this to our Ideas forum at https://aka.ms/BusinessCentralideas, or vote up the idea if its already there. We're constantly monitoring top Ideas and will consider them for a future release. |
When using a variant for generic code, there doesn't seem to be a way to differentiate between overloaded RecordRef.Copy()-function calls.
If the variant was a recordref, I could do
But in this case the variant is a Record, which is precisely why I need recref.copy.
"The call is ambiguous between the method 'Copy(var Table, [Boolean])' defined in Class 'RecordRef' by the extension '' and the method 'Copy(RecordRef, [Boolean])' defined in Class 'RecordRef' by the extension ''.AL[AL0196]"
A type "Table" does not exist and we cannot do a cast, so this can probably not be done unless the Copy-function is split into two..?
The text was updated successfully, but these errors were encountered: