I realized that I can use ExecuteSOQL to run a SOQL query within a flow. It works perfect. But when I use a SUM() and Group By sentence, the flow display Invalid interview state after the screen 01, so I'm not able to see screen 02
*This only applies when Group By is in the query, otherwise, it works fine.
Any Ideas how to fix this?
Action Get Records looks like this:
**Edit, var_query contains something like this:
"SELECT Date__c, SUM(Hours__c) FROM Revenue_Forecast__c Where Opportunity__r.IsClosed = true and (Opportunity__c='xxxx' or Project__c='yyyyy') group by Date__c"
Best Answer
ExecuteSOQL is an open source contribution to the Lightning Flow Community that is a LWC + invocable Apex class
The invocable Apex class at its heart takes the incoming SOQL string and does
and passes back the sobjects to the Flow.
If
soqlQuery
is an aggregate query, then the return is a list ofAggregateResult
objects.AggregateResult
extendsSObject
and the ExecuteSOQL component allows you to chooseAggregateResult
as the value forObject for SObjects
input field in the UI. Do not useRevenue Forecast
as the SOQL doesn't returnRevenue Forecast
If you run in debug, you can see the field names in the
AggregateResult
sobject collection. Unless you use aliases in your SOQL, theSUM(Hours__c)
will have field name ofexpr0
.You can read more about processing
AggregateResult
objects in the Apex doc