You need to sign in to do that
Don't have an account?
bob4
Check if selected picklist value is one among other picklist
Consider 2 picklists
<apex:inputfield value="controller.picklist1__c"/>
and the second picklist, 'picklist2__c' has some values in it, Is there any way to check if selected value in picklist1__c is in picklist2__c. Thanks.
Like, IF(Selectedvalue(picklist1) is one of the field values of (picklist2))
<apex:inputfield value="controller.picklist1__c"/>
and the second picklist, 'picklist2__c' has some values in it, Is there any way to check if selected value in picklist1__c is in picklist2__c. Thanks.
Like, IF(Selectedvalue(picklist1) is one of the field values of (picklist2))
Let me know if you have any specific question.
Regards,
Digamber Prasad
You can call onchange JavaScript method to invoke action where you can check whether the selected picklist1__c is in picklist2__c.
Regards,
Zedroid.
The code in the following post is a property you can add to your controller. The set will contain all of the picklist values that are in common between the two picklists. You can check to see if the chosen value is a shared value with:
set_PicklistValuesInCommon.contains( chosenValue )
In the code, replace "myObject__c" with whatever your object name is.
Let me know if you have any questions.
Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
public Set<String> set_PicklistValuesInCommon
{
get
{
if ( set_PicklistValuesInCommon == null )
{
Set<String> set_Picklist1Values = new Set<String>();
for ( Schema.PicklistEntry entry : MyObject__c.Picklist1__c.getDescribe().getPicklistValues() )
{
set_Picklist1Values.add( entry.getValue() );
}
Set<String> set_Picklist2Values = new Set<String>();
for ( Schema.PicklistEntry entry : MyObject__c.Picklist1__c.getDescribe().getPicklistValues() )
{
set_Picklist2Values.add( entry.getValue() );
}
set_PicklistValuesInCommon = set_Picklist1Values;
set_PicklistValuesInCommon.retainAll( set_Picklist2Values );
}
return set_PicklistValuesInCommon;
}
private set;
}
</pre>
-Glyn