You need to sign in to do that
Don't have an account?

Problem with ContentDocument Trigger
Hello,
I can't get the LinkedEntityId form ContentDocumentLink because the record is not created if the trigger fires. I tried to add Trigger.isAfter but the contentdocumentlink is still not created.
How can I solve it?
The goal is to check if the new uploaded document is related to sobject Mediathek__c.
Thanks,
Sascha
I can't get the LinkedEntityId form ContentDocumentLink because the record is not created if the trigger fires. I tried to add Trigger.isAfter but the contentdocumentlink is still not created.
How can I solve it?
The goal is to check if the new uploaded document is related to sobject Mediathek__c.
trigger ContentDocumentMediathek on ContentDocument (after insert) { if (Trigger.isAfter) { for (ContentDocument objCD : trigger.new) { ContentDocument newCD = Trigger.newMap.get(objCD.Id); for (ContentDocumentLink cdl : [SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId = :newCD.Id]) { System.debug('cdl.LinkedEntityId: ' +cdl.LinkedEntityId); If(cdl.LinkedEntityId.getSObjectType() == Mediathek__c.SObjectType) { system.debug('super');} } } } }
Thanks,
Sascha
Can you try the trigger on ContentDocumentLink object itself?
Thanks,