You need to sign in to do that
Don't have an account?
Sain
How to Make Picklist Mandatory(any value Reuqired), if we select any value another Picklist
Hi,
I have a two Picklist A and B, if i select any value in picklist A, it should has to be make Picklist B Mandatory(Required to select a value in Picklist B).
Please share, Does anyone has some sample code or can point me in the right direction?
Many thanks!!!
I have a two Picklist A and B, if i select any value in picklist A, it should has to be make Picklist B Mandatory(Required to select a value in Picklist B).
Please share, Does anyone has some sample code or can point me in the right direction?
Many thanks!!!
trigger RequirePicklistValue on MyObject__c(before insert, before update) {
for(MyObject__c obj: trigger.new){
//if((obj.Picklist1 =='X' || obj.Picklist1=='Y') && obj.Picklist2 == null){
if( obj.Picklist1 != null){
if(obj.Picklist2 == null){
obj.Picklist2.addError('value Should be Reuired');
//}
}
}
}
}
Regards,
Shaik
All Answers
You can use dependant picklists for that, and set the second picklist field as required on the page layout.
The second picklist will be required only if there is a possible value based on the first picklist value.
Jerome
trigger RequirePicklistValue on MyObject__c(before insert, before update) {
for(MyObject__c obj: trigger.new){
//if((obj.Picklist1 =='X' || obj.Picklist1=='Y') && obj.Picklist2 == null){
if( obj.Picklist1 != null){
if(obj.Picklist2 == null){
obj.Picklist2.addError('value Should be Reuired');
//}
}
}
}
}
Regards,
Shaik