6 risposte
Hi,Use below code:-trigger ContentDocumentLinkTrigger on ContentDocumentLink ( after insert, after update, after delete ) { List<ContentDocumentLink> cdls = ( Trigger.new == null ? Trigger.old : Trigger.new ); Set<ID> parentIds = new Set<ID>(); for (ContentDocumentLink cdl : cdls) { parentIds.add( cdl.LinkedEntityId ); } for (List<Account> account : [SELECT Id, (SELECT Id FROM ContentDocumentLinks LIMIT 1) FROM Account WHERE Id IN :parentIds]) { for (Account acc : account) { acc.Cb__c = ( acc.ContentDocumentLinks.size() > 0 ); } UPDATE account; } }Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.Thanks.