static void filterExample(Args _args)
{
container products = [22565421967, 22565421968, 22565421973, 22565421976];
TmpRecIdFilter tmpFilter;
InventTable inventTable;
TmpRecIdFilter getTmpFilterTable(container _referenceValues)
{
TmpRecIdFilter tmpRecIdFilter;
RefRecId refRecId;
int length = conLen(_referenceValues),
i;
for (i = 1; i <= length; i++)
{
refRecId = conPeek(_referenceValues, i);
tmpRecIdFilter.RefRecId = refRecId;
tmpRecIdFilter.doInsert();
}
return tmpRecIdFilter;
}
tmpFilter = getTmpFilterTable(products);
while select inventTable
join tmpFilter
where inventTable.Product == tmpFilter.RefRecId
{
abs(1);
}
}
And a method using RecordInsertList. It should be executed only at server side, otherwise will fail with following error:static server TmpRecIdFilter getTmpFilterTableServer(container _referenceValues)
{
TmpRecIdFilter tmpRecIdFilter;
RefRecId refRecId;
int length = conLen(_referenceValues),
i;
RecordInsertList invoicesToBeInserted = new RecordInsertList( tableNum(TmpRecIdFilter), // table id
true, // skip insert
true, // skip database log
true, // skip events
true, // skip aos validation
true, // skip RLS validation
tmpRecIdFilter); // buffer where records will be inserted
new SkipAOSValidationPermission().assert();
for (i = 1; i <= length; i++)
{
refRecId = conPeek(_referenceValues, i);
tmpRecIdFilter.RefRecId = refRecId;
invoicesToBeInserted.add(tmpRecIdFilter);
}
invoicesToBeInserted.insertDatabase();
return tmpRecIdFilter;
}
Do not forget to clear CountryRegionCodes property on TmpRecIdFilter table.If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a CoffeeAlso, we can use TmpQueryRangeValue, to create range based on another type than RecId (int64), Example: InventTransId (str)
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.