You need to sign in to do that
Don't have an account?
SOQL query returns no results Trigger but returns a row in Developer Console
I have the following code snippet in a Helper class that's being called by an After Insert trigger (modified to demonstrate my objective):
The debug output is showing me that I'm getting zero results. However, when I run the same query in the debug console, I see the single row returned that I'm expecting.
I have included without sharing on the trigger Helper class even though my understanding is that's not necessary in a trigger, but it doesn't change my results.
Can anyone offer any clues as to what I may be experiencing here?
Set<Id> reuseIds = new Set<Id>(); reuseIds.add('a0g0R000001VnjMQAS'); List<ContentDocumentLink> allLinks = [SELECT Id, LinkedEntityId, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN :reuseIds]; System.debug('allLinks size: ' + allLinks.size());
The debug output is showing me that I'm getting zero results. However, when I run the same query in the debug console, I see the single row returned that I'm expecting.
I have included without sharing on the trigger Helper class even though my understanding is that's not necessary in a trigger, but it doesn't change my results.
Can anyone offer any clues as to what I may be experiencing here?
Does executing that script in the anonymous window retrieve the record or not?
I will also try to hardcode the 15 digits Id instead of the 18 digits one ('0R000001VnjMQAS')