My_Test_Repo/force-app/main/default/classes/testApex.cls

31 lines
1.3 KiB
OpenEdge ABL

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