Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
if (Trigger.isUpdate) {
//Create a list of old and new Values
public List<Sales_Support_Request__c> oldList = new List<Sales_Support_Request__c>();
public List<Sales_Support_Request__c> newList = new List<Sales_Support_Request__c>();
//populate both the list
//lets create two maps to compare
Map<Id, Sales_Support_Request__c> oldMap = new Map<Id, Sales_Support__c>();
Map<Id, Sales_Support_Request__c> newMap = new Map<Id, Sales_Support__c>();
//Populate the Map iterating through List
// use put method to add values to map
for(Sales_Support_Request__c rec : oldList)
for(Sales_Support_Request__c rec : newList)
//Now we are loaded with data we needed
//Now lets say you want to compare the old account with new account
//here is how you do it while looping through new map
for(Sales_Support_Request__c rec : newList)
Sales_Support_Request__c createSSR = new Sales_Support_Request__c();
//get old value from old map
if(rec.Account__c != oldMap(
//if the account is changed then set account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment