Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger attachmentTrigger on Attachment (after update, after insert) {
- string placeholder = '<img alt="{0}" src="/servlet/servlet.FileDownload?file={1}"></img>';
- list<contact> contactToUpdate = new list<Contact>();
- for (Attachment att :trigger.new) {
- if (att.ParentId.getSobjectType() == Schema.Contact.SObjectType){
- List<String> fillers = new String[]{att.name,string.valueOf(att.id)};
- contactToUpdate.add(new Contact(id = att.ParentId,
- pname__c = att.name,
- picture__c = String.format(placeholder, fillers)));
- }
- }
- update contactToUpdate;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement