You need to sign in to do that
Don't have an account?
Jess Robinson
System.LimitException: Maximum stack depth reached: 5 on Database.query
Hi all,
I am seeing this exception: System.LimitException: Maximum stack depth reached: 5
on a Database.query call in a scheduled job. Have tried the job running as Scheduled, Asynchronous and Queueable and it happens in every instance, but only intermittently. Could anyone shed any light on what might be causing this?
Code:
I am seeing this exception: System.LimitException: Maximum stack depth reached: 5
on a Database.query call in a scheduled job. Have tried the job running as Scheduled, Asynchronous and Queueable and it happens in every instance, but only intermittently. Could anyone shed any light on what might be causing this?
Code:
string soqlString = 'select count(Id) activeCount, OwnerId from '+team.Object_name__c+' where '+ (team.Object_name__c == 'Lead' ? 'IsConverted = false and ' : '') + 'OwnerId IN :memberUserIdsList and '+team.Object_active_status_field_name__c+' IN :statusValueList'+ ' group by OwnerId'; for (sObject sObj : Database.query(soqlString)) { <-- Exception occurring here AggregateResult ar = (AggregateResult)sObj; id memberOwnerId = (string)ar.get('OwnerId'); integer activeObjectCount = (integer)ar.get('activeCount'); Team_member__c teamMember = memberByUserIdMap.get(memberOwnerId); teamMember.Number_of_active_objects__c = activeObjectCount; }
I suspect your IN clause is the problem here, please review the below limits
please refer to
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_comparisonoperators.htm