+ Start a Discussion
etechcareersetechcareers 

Instead of repeating each field???

Hi I have a trigger that would insert any changes into an object...

but I need to know instead of me writing every field and stating if null then...

Here is my code:

 

if (Trigger.old[0].Email != null && Trigger.old[0].LastName != null && (
    Trigger.old[0].Operations__c != Trigger.new[0].Operations__c ||
    Trigger.old[0].Interests__c != Trigger.new[0].Interests__c ||
    Trigger.old[0].Details__c != Trigger.new[0].Details__c ||
    Trigger.old[0].Int__c != Trigger.new[0].Int__c ||
    Trigger.old[0].Contact_Status__c != Trigger.new[0].Contact_Status__c )) {

 

Anyhelp please would help...

 

Shashikant SharmaShashikant Sharma

No other way if your requirement need those conditions you can not write your code any other way , just write your code for bulk trigger if you have not as you hav eused trigger.new[0] instead on trigger.new[i] with any index variable so its looks like you have not developed it for bulk handling. The answwer to original question is no substitute way.