Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Re: Iterating Group standard object records in sal...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Iterating Group standard object records in salesforce
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-16-2013 01:23 AM
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.
Re: Iterating Group standard object records in salesforce
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-16-2013 02:47 AM
Can you post the whole code block ?
Re: Iterating Group standard object records in salesforce
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-16-2013 03:55 AM
public class AutoDeleteSubscriptions2
{
public List<User> usr ;
public List<EntitySubscription> es ;
public Map<String,ID> m1 = new Map<String,ID>();
public Map<String,ID> m2 = new Map<String,ID>();
public List<EntitySubscription> lest;
public List<EntitySubscription> es1;
public List<EntitySubscription> es2;
public List<Group> grp ;
public void deleteSubscriptions()
{
usr = [SELECT Id FROM User];
es = [SELECT Id,SubscriberId FROM EntitySubscription];
grp = [SELECT Id FROM Group];
System.debug('************GRoup****************'+g
System.debug(' Entity Subscription size : '+es.size()+' User Size : '+ usr.size());
for(User u : usr)
{
m1.put(u.Id,u.Id);
}
System.debug('***********User Ids**********'+m1.values()+'*****Map Size****'+m1.size());
System.debug(' Entity Subscription size : '+es.size());
for (EntitySubscription e : es)
{
m2.put(e.SubscriberId,e.SubscriberId);
}
System.debug('*************Entity Subscription User Ids***********'+m2.values()+'*****Map Size****'+m2.size());
// Comparing two map values
Set<String> ls = m1.keySet();
Set<String> ls1 = m2.keySet();
System.debug('**************List Elements*****************'+ls.size()+'************
for (Id i :ls)
{
for ( Id j : ls1)
{
System.debug(' I = '+i +' J = '+j);
if ( i == j)
{
System.debug(' Both are equal ' + i +'***************** '+ j);
List<EntitySubscription> es = [select Id from EntitySubscription where SubscriberId =: j];
System.debug('**************************List Size ***********************'+es.size());
if(es.size() > 20)
{
es1 = [select Id from EntitySubscription where SubscriberId =: j and ParentId NOT IN :usr order by CreatedDate limit 5];
delete es1;
}
}
}
}
}
}
In query now i added the user lisr like NOT IN : usr the same way want to check with the group.
Re: Iterating Group standard object records in salesforce
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-16-2013 03:57 AM
In the query now i want to retrive all the EntitySubscriptions except the users and group remaining i want to retrive for that am trying put both the lists.
NOT IN : usr and NOT IN : grp
for group am getting error please help me out on this.

