function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GOAL_KEEPERGOAL_KEEPER 

Query to complex when NOT IN Items contains more than 500 ?

Hi guys I have this problem when I am querying using a user with a platform license. If the NOT IN part of the SQOL statements goes more than 500 items then it fails, but if I use a user with full a salesforce license it works fine.

 

 

This is what I am trying to do, query all users who are following me at least 10000

 

public static List<EntitySubscription> getEntitySubscriptionTest(Id parentId){
        Set<EntitySubscription> lastSubscriptions = new Set<EntitySubscription>();
        
        for (Integer queryCount = 0; queryCount < 50; queryCount++) {
            
            System.debug('### LAST IDS COUNT: ' + lastSubscriptions.size());
            
            for (List<EntitySubscription> thisEntitySubscription : [SELECT Id, SubscriberId, ParentId, Subscriber.Name
                FROM EntitySubscription WHERE ParentId = :parentId AND Id NOT IN :lastSubscriptions LIMIT 200]) {
                    
                lastSubscriptions.addAll(thisEntitySubscription);
            }
        }

        System.debug('### CONNECTION COUNT: ' + lastSubscriptions.size());
        return new List<EntitySubscription>(lastSubscriptions);
    }