You need to sign in to do that
Don't have an account?
Larry Wasser
SOQL Query on Collaboration Group fails only in live code, not in Execute Anonymous Window or Query Tab of Developer Console
Simple SOQL Query fails to yield results in live Apex code, but succeeds in Developer Console Execute Anonymous Window and in Query Editor Tab.
public void importProgramCollaborationGroupTable(){
List<CollaborationGroup> allCollabGroups = [SELECT Id, Name FROM CollaborationGroup];
}
public void importProgramCollaborationGroupTable(){
List<CollaborationGroup> allCollabGroups = [SELECT Id, Name FROM CollaborationGroup];
}
Hope this will be helpful!!
This might be due to the missing permissions. The user that you are using to run the batch might not have accesss to those records. You have two options to make it work:
- Make your batch to run on without sharing mode, only if this is feasible.
- Give the neccessary permisisons to the user from which batch is scheduled or change the running user.
Let me know if you need any more help on this.Thanks,
Abhishske Bansal.
I see this is the same ask as https://salesforce.stackexchange.com/questions/318930/soql-query-on-collaboration-group-fails-only-in-live-code-not-in-execute-anonym
Can you please share your inputs on whether the answer to it helped. If it does, please mark this answer as best to close the thread.Happy to answer any follow-up queries.Thank you
Thanks for your advice. The logs show what I was expecting. The Batch is being initiated in an Event Trigger, so the running user is autoproc@00d19000000fd64eag. Resulting logs follow below:
11:39:56.0 (398761710)|USER_DEBUG|[184]|DEBUG|UserInfo.getUserName(): autoproc@00d19000000fd64eag
11:39:56.0 (399519375)|SOQL_EXECUTE_BEGIN|[186]|Aggregations:0|SELECT Id, Name FROM CollaborationGroup
11:39:56.0 (399552908)|LIMIT_USAGE|[186]|SOQL|3|200
11:39:56.0 (399567797)|LIMIT_USAGE|[186]|AGGS|0|600
11:39:56.0 (402658123)|SOQL_EXECUTE_EXPLAIN|[186]|TableScan on CollaborationGroup : [], cardinality: 9, sobjectCardinality: 9, relativeCost 2.617
11:39:56.0 (402673607)|SOQL_EXECUTE_END|[186]|Rows:0
Additional ideas are welcome!
Larry
Unfortunately, the behavior is the same regardless of whether the class is declared as with sharing or without sharing.
I believe that I've set all the appropriate permissions, but may have missed something. Open to commonly overlooked permissions with respect to CollaborationGroups/Chatter Groups.
Thanks,
Larry
Unfortunately, the recommendation on stack exchange did not provide forward progress. The guidance was similar to that provide by Abhishek above.
Kind regards,
Larry
Please check if Enable Chatter is checked for the profile of the user autoproc@00d19000000fd64eag under administritive permission.
Refer this link: https://help.salesforce.com/articleView?id=collab_pbr_profiles.htm&type=5 (https://help.salesforce.com/articleView?id=collab_pbr_profiles.htm&type=5)
Hope this will be helpful!!
Unfortunately, autoproc is a system user that cannot be edited. However, we did have success with this kind of activity outside of a batch context. I'm wondering if the combination of Batchable, Event Trigger, and CollaborationGroup is uncovering a strange issue.
Thanks.
Larry
The issue appears to be directly related to the Automated User (i.e. autoproc@....).
Just filed a case with Salesforce support.
Larry