You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Update field with old uploaded Ids by trigger
Hello, I have a trigger on ContentDocumentLink. When a file is uploaded the trigger populates a field. The problem is, that I need to reupload the Ids in every record now. Could you tell me an option so i can populate if with the latest Id in every record?
trigger ContentIdEintragen on ContentDocumentLink (after insert) { map<id,id> parentids = new map<id,id>(); for(ContentDocumentLink cdl:trigger.new){ parentids.put(cdl.LinkedEntityId,cdl.ContentDocumentId); } List<Mediathek__c> ContentDocumentIdupdate = new List<Mediathek__c>(); for(Mediathek__c mt:[select id from Mediathek__c where id IN:parentids.keyset()]){ if(parentids.containskey(mt.id)){ mt.ContentDocumentID__c = parentids.get(mt.id); ContentDocumentIdupdate.add(mt); } } update ContentDocumentIdupdate; }
If you have uploaded two files then both documents ids need to capture in parent record?
Thanks!!