Skip to main content
i have picklist field Position in that IT and NON IT. i need to select any one of them when im creat record soppose i didnt slect nay value at that time trigger is fired.

 

for tha purpose i wrote on triger

 

trigger position on Position__c (Before Insert, Before Update ) {

 

for(Position__c p : Trigger.New){

 

 IF(p.Position__c!='Null')

 

 p.addError('U must be select position either IT or NON_IT');

 

 

 

}

 

}

 

 but it didnt work how it will be write code please tell me
4 个回答
  1. 2016年4月27日 18:04
    Hi Veera,

     

    Try this.

    trigger position on Position__c (Before Insert, Before Update ) {

    for(Position__c p : Trigger.New){

    if(p.Position__c == null )

    p.addError('U must be select position either IT or NON_IT');

    }

    }

     

    This should do the trick and please consider Jeff's suggestion.

     

    Thanks,

     

    Naval
0/9000