function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Trigger that gets Old and New Values



I was just wondering if its possible to write a trigger that will be able to post both old and new values of a field (Email) to a URL?  E.g Http://


Im pretty sure i can handle the URL bit with HTTPRequest class. 


What im wondering is how to access both new and old values in a trigger? I read around and saw that there is a Trigger.Old process i could use through a for loop, would this work? Could i just have one for loop for the old emails, add them to a list, do the same with new emails then put them both through a for loop that visits the URL?


Any help or pseudocode would be awesome!!! I apologize for not writing any of my own code in here, but im going to attempt it today and post any i can! :)





Edit: So i just realized il need to use @future method because i cant use HTTPRequest while in a trigger :) Meaning il have to pass the old and new triggers values to the class! :) 

Message Edited by Brookesy-- on 02-05-2010 12:41 AM
I don't see any reason why you wouldn't be able to do this.  There are probably various ways of doing this, but your initial thoughts seem reasonable.
Here's some code that may help - I haven't compiled this, so you may get typos:

List<String> oldEmails=new List<String>(); List<String> newEmails=new List<String>(); for (MyType__c oldEle : trigger.old) { oldEmails.add(oldEle.Email_Address__c); newEmails.add(trigger.newMap.get(; } // do what you need to with the lists here.