+ Start a Discussion
SFDC Coder 8SFDC Coder 8 

Updating status filed to default

Hi All,
I have three phone number fileds (P1__c,P2__c,P3__c) in Contact and I have three status pick list (St1__c,St2__c,St3__c) values for all three fields.
When ever user is updating new number in phone numbers, I want to update all three status pick list to None value.

How can I do this?
Please help me

Thanks in Advance
Best Answer chosen by SFDC Coder 8
sfdcMonkey.comsfdcMonkey.com
hi SFDC Coder
try below trigger for do it
trigger statusChnageOnUpdate on Contact ( before update) {
    
    For (Contact c : Trigger.New) {
       for(Contact cOld :Trigger.old){
        if(c.P1__c != cOld.P1__c || c.P2__c != cOld.P2__c || c.P3__c != cOld.P3__c  ) { 
             c.St1__c = null;
             c.St2__c = null;
             c.St3__c = null;
            
          }
       }

    }
}
I hope it helps you
Mark it best answer if it helps you so it make proper solution for others :)
Thanks
 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi SFDC Coder
try below trigger for do it
trigger statusChnageOnUpdate on Contact ( before update) {
    
    For (Contact c : Trigger.New) {
       for(Contact cOld :Trigger.old){
        if(c.P1__c != cOld.P1__c || c.P2__c != cOld.P2__c || c.P3__c != cOld.P3__c  ) { 
             c.St1__c = null;
             c.St2__c = null;
             c.St3__c = null;
            
          }
       }

    }
}
I hope it helps you
Mark it best answer if it helps you so it make proper solution for others :)
Thanks
 
This was selected as the best answer
SFDC Coder 8SFDC Coder 8
Hi Piyush,
Can you please suggest me test class for the above trigger?