Advertisement
Guest User

Untitled

a guest
May 30th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. trigger attachmentTrigger on Attachment (after update, after insert) {
  2. string placeholder = '<img alt="{0}" src="/servlet/servlet.FileDownload?file={1}"></img>';
  3. list<contact> contactToUpdate = new list<Contact>();
  4.  
  5. for (Attachment att :trigger.new) {
  6. if (att.ParentId.getSobjectType() == Schema.Contact.SObjectType){
  7.  
  8. List<String> fillers = new String[]{att.name,string.valueOf(att.id)};
  9. contactToUpdate.add(new Contact(id = att.ParentId,
  10. pname__c = att.name,
  11. picture__c = String.format(placeholder, fillers)));
  12. }
  13. }
  14. update contactToUpdate;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement