How to retrieve AccountId on insert of file.
system.debug('LinkedEntityId $$$$'+LinkedEntityId)
always gives OwnerId.
But after insert of file, I can retrieve two rows from below query on ContentDocumentLink - one row with AccountId(LinkedEntityId) and one row with OwnerID(LinkedEntityId)
SELECT LinkedEntityId, Id, ContentDocumentId FROM ContentDocumentLink where ContentDocumentId ='069r00000002COX'
trigger UpdateAccountWithFileLink on ContentDocumentLink (after insert) {
list<Id> accIdList = new list<Id>();
for (ContentDocumentLink cdl : trigger.new) {
system.debug('LinkedEntityId $$$$'+LinkedEntityId);
if(String.valueOf(cdl.LinkedEntityId).startswith('001')){
accIdList = cdl.LinkedEntityId;
}
}
}