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
Michael Kolodner 13Michael Kolodner 13 

Code Help: Got a list of ContentDocumentLinks, want to end up with a list of the LinkedEntityIds of a certain sObject type

I've got a list of ContentDocumentLinks that's going to come from a trigger. (Or, in my current testing phase, is from this SOQL query:
ContentDocumentLink cdl : [Select Id, LinkedEntityId From ContentDocumentLink WHERE LinkedEntityId in ( SELECT Id FROM User)]

I need to loop through that and end up with a list of the LinkedEntityIds that are of a particular object. (In this case, a custom object Expenses__c.)

Help please?
Nayana KNayana K
Set<Id> setExpenseId = new Set<Id>();
for(ContentDocumentLink cdl : [Select Id, LinkedEntityId From ContentDocumentLink WHERE LinkedEntityId in ( SELECT Id FROM User)])
{
if(cdl.LinkedEntityId.getSObjectType() == Expenses__c.sObjectType)
{
setExpenseId.add(cdl.LinkedEntityId);
}
}
Michael Kolodner 13Michael Kolodner 13
Thanks, Nayana! I'll try to put that to work later today.