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
Sarah Robertson 4Sarah Robertson 4 

Trigger which fires when an apex picklist isn't selected

Hi i'm trying to create a trigger which fires before a record is saved, when the mandatory field support group is not completed. It's not working any ideas where i'm going wrong ? 

Thanks here 's my code : 

trigger UpdateSupportGroup on Account (before insert) {
    For(Account a : Trigger.new){
    if ( ISPICKVAL( a.Support_Group__c, "--None--")){
   
    

        a.Support_Group__c='MSP';
    }
}}
sfdc  novicesfdc novice
Hi Sarah,

Try this Code it will work...
 
trigger UpdateSupportGroup on Account (before insert) {

    for(Account a : Trigger.new){

    	if (a.Support_Group__c == Null){
   
    		a.Support_Group__c='MSP';
    	}

    }

}

Thanks...