Hi,
I would like to use a variable as a datasource in a ForAll loop but cannot work out if this is possible or not.
This is what I have so far - I am creating a collection which has the variable value in it that I need to use.
The variable needs to be in the FILTER Datasource - below it shows as 'Shipments-FY2024' - it could be 'Shipments-FY2019' 2020, 2021 etc. Each of the Datasources exist as their own dataverse tables in my app.
ClearCollect(
colDS,
Filter(
tblYears,
IsActive = true
)
);
Clear(colTest);
ForAll(
colDS As DataLoop,
Collect(
colTest,
Sort(
Filter(
'Shipments-FY2024',
Solution = "CompanyName" ),
NetRevenueUSD,
SortOrder.Ascending
)
)
)
I have no errors with the above but the datasource is static - I need it to change for each year.
The following gives me a Invalid Data Type which then of course errors on the Solution = "CompanyName" as Solution does not exist.
ForAll(
colDS As DataLoop,
Collect(
colTest,
Sort(
Filter(
DataLoop.YearDataSource,
Solution = "CompanyName" ),
NetRevenueUSD,
SortOrder.Ascending
)
)
)
I have tried changing the value that is stored in the tblYears e.g. single quotes in the field 'Shipments-FY2024' or just plain Shipments-FY2024.
Any hints from anyone on how to make the variable be seen as a dataverse table(datasource) is appreciated.
I looked at using SET / UpdateContext but they are not allowed in a ForAll.
My current work around is using a Switch for each year - but this will require maintenance for each year.