Here i am unable to fetch Contectdocumentlink records. when i am hardcoding with Id it's getting records properly. Can you suggest, what is the wrong here.

trigger Contenttrigger on ContentDocument (before delete, after Insert) {

if(trigger.isAfter && trigger.IsInsert) {


public static void sendEmail(list<ContentDocument> docrecods) {
    Schema.DescribeSObjectResult inv = WorkOrder.sObjectType.getDescribe();
    String invKeyPrefix = inv.getKeyPrefix();
    list<Id> contentDocId = new list<Id>();
    Map<Id, Id> contDocLinkedMap = new Map<Id, Id>();
    for(ContentDocument con : docrecods) {
        System.debug('con.Id is ++++' + con.Id); // It is printing ID
        system.debug('contentDocId=== '+contentDocId);
    list<ContentDocumentLink> contentdocs = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE  ContentDocumentId  IN: contentDocId ]; //
    if(contentdocs.size() > 0){
        system.debug('YEs Got records');
    for(ContentDocumentLink cdl : contentdocs) {    
        system.debug('LinkedEntityId=== '+cdl.LinkedEntityId);
        if(cdl.ContentDocumentId == contentDocId[0]){
             contDocLinkedMap.put(cdl.ContentDocumentId, cdl.LinkedEntityId);
        System.debug('map__++++' + contDocLinkedMap);

For this user View All Data Permission was enabled. I am trying to execute this from the partner community. I followed all these steps, But none of them did not work. do i need to enable any new permission for getting this record.

Thank you in advance.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.