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
Larry WasserLarry Wasser 

SOQL Query on CollaborationGroup returns zero rows within Platform Event Trigger transaction context

Simple SOQL query on CollaborationGroup fails when executed within a platform event trigger.

The query is successful within an object trigger or through an @invocableMethod.

Am I missing something? 
Does the autoproc user not have permissions on the CollaborationGroup object?

Here is the SOQL query:
List<CollaborationGroup> allGroups = [SELECT Id, Name FROM CollaborationGroup];

17:20:08.0 (19515769)|VARIABLE_SCOPE_BEGIN|[21]|event|CORE_Automation_Started_Event__e|true|false
17:20:08.0 (19612928)|VARIABLE_ASSIGNMENT|[21]|event|{"Program_Instance_Id__c":"a0919000003nNH5AAM","CreatedById":"0050B0000088oW9QAI","ReplayId":"156295","Role__c":"Active Learner","CreatedDate":"2020-09-09T21:20:07.000Z","Id":"e00xx0000000eetAAA","Action__c":"Add"}|0x4a46a6e1
17:20:08.0 (19626683)|STATEMENT_EXECUTE|[21]
17:20:08.0 (19659009)|HEAP_ALLOCATE|[23]|Bytes:3
17:20:08.0 (19695513)|STATEMENT_EXECUTE|[23]
17:20:08.0 (19698608)|STATEMENT_EXECUTE|[25]
17:20:08.0 (19702531)|HEAP_ALLOCATE|[25]|Bytes:73
17:20:08.0 (19715368)|SYSTEM_METHOD_ENTRY|[25]|System.debug(ANY)
17:20:08.0 (19734053)|USER_DEBUG|[25]|DEBUG|Entered CoreAutoAddStartEventTriggerHandler -- Add Automation Start Event
17:20:08.0 (19746165)|SYSTEM_METHOD_EXIT|[25]|System.debug(ANY)
17:20:08.0 (19751195)|STATEMENT_EXECUTE|[35]
17:20:08.0 (19755079)|HEAP_ALLOCATE|[35]|Bytes:39
17:20:08.0 (19781887)|HEAP_ALLOCATE|[35]|Bytes:4
17:20:08.0 (20161802)|SOQL_EXECUTE_BEGIN|[35]|Aggregations:0|SELECT Id, Name FROM CollaborationGroup
17:20:08.0 (20202930)|LIMIT_USAGE|[35]|SOQL|1|100
17:20:08.0 (20221448)|LIMIT_USAGE|[35]|AGGS|0|300
17:20:08.0 (34398664)|SOQL_EXECUTE_EXPLAIN|[35]|TableScan on CollaborationGroup : [], cardinality: 9, sobjectCardinality: 9, relativeCost 2.617
17:20:08.0 (34422629)|SOQL_EXECUTE_END|[35]|Rows:0
17:20:08.0 (34447997)|LIMIT_USAGE|[35]|SOQL_ROWS|0|50000

Thanks,
Larry 
SwethaSwetha (Salesforce Developers) 
HI Larry, Was this working earlier? Is it possible to share narrowed down code snippet that I can reproduce in my org to confirm if it is a salesforce bug or org related issue?

Thanks