Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String[] changedFields = new String[]{};
- for(WorkI_Item__c c: trigger.new){
- for(string s: fields){
- if(c.get(s) != trigger.oldMap.get(c.Id).get(s)){
- changedFields.add('Contact: ' + c.Id + ' - ' + s + ' - old:' + trigger.oldMap.get(c.Id).get(s) + ' new:' + c.get(s));
- }
- }
- }
- if(changedFields.size()>0){
- messaging.singleEmailMessage mail = new messaging.singleEmailMessage();
- // mail.setToAddresses(new string[]{UserInfo.getownerid()});
- // mail.setReplyTo(UserInfo.getUserEmail());
- mail.setSubject('Cantact updated');
- string htmlBody = '';
- for (String s : changedFields){
- htmlBody += '<div>' + s + '</div>';
- }
- mail.setHtmlBody(htmlBody);
- Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
- }
Add Comment
Please, Sign In to add comment