public class testApex { public static void method(){ try{ //collecting contentdocumentlink record from contentdocumentlink List cdlList = [SELECT Id,ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId='0695j00000Hql43AAB']; system.debug('ContentDocumentLink Record:'+cdlList); //collecting linkedentityid to find object from contentdocumentlink List LinkedEntyId = new List(); for (ContentDocumentlink cd1 :cdlList) { LinkedEntyId.add(cd1.LinkedEntityId); } system.debug('LinkedEntityId'+LinkedEntyId); //colleting those records where linkedentityid==contactid ListcList=[SELECT Id,LastName,Profile_Image__c,Description FROM Contact WHERE Id =:LinkedEntyId]; system.debug('Contact list where attachment is added'+cList); List updatedContacts = new List(); for (Contact contact : cList) { contact.Description = 'attachment inserted'; updatedContacts.add(contact); } update updatedContacts; } catch(Exception e){ system.debug('Error Message:'+e); } } }