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
KRISH9KRISH9 

Iterating Group standard object records in salesforce

The following in the SOQL query for Users

 

List<User> u = [SELECT Id FROM User];

 

Am able to get the id to iterate. Now i would like to get the id of Group standard object

List<Group> g = [SELECT Id FROM Group];

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr ]; 

 

am retriving all entity subscriptions whose subscriber id not in the list of users. It is working fine. Now i want to retrive the entity subscriptions whose subscriber id not in the group also. For that i am writing the query like as above 

 

List<EntitySubscription>   es1 = [select Id from  EntitySubscription where SubscriberId =: j and ParentId NOT IN :grp ]; 

 

Am getting the following error. 

 

Error: AutoDeleteSubscriptions2 Compile Error: Invalid bind expression type of SOBJECT:Group does not match domain of foreign key

 

Please any one can help me on this how to retrive the entity subscriptions whose subscriber id not in the group.

 

 

 

 

Jia HuJia Hu
ParentId of EntitySubscription is the ID of the record or user which the user is following.

Since you can't follow a Group in SFDC, the ParentId can't be Group id.
Jia HuJia Hu
By any change, do you mean Chatter Group?