You need to sign in to do that
Don't have an account?
Siana Dcruz
How to map label names to picklist values of two different objects.
Hi all,
In the below code, I am mapping
label1 to time1,
label2 to time2,
label3 to time2,
label4 to time3
All these are the picklist values in the field time__c. Now i want
1)label2 to be mapped to 'time2'(which is done) and also to 'reason2' picklist value of reason__c field.
2)label3 to be mapped to 'time2' of time__c field and 'reason3' of reason__C field.
Anyone Please suggest me how can I achieve this.
public List<SelectOption> getTimeOptions()
{
List<SelectOption> options = new List<SelectOption>();
List<String> times= this.getDynamicPicklistValues('Intake__c', 'time__c');
// List<String> reasonTypes = this.getDynamicPicklistValues('Intake__c', 'Reason__c');
for (String time: times)
{
if(time== 'time1')
options.add(new SelectOption(time,'label1'));
if(time== 'time2')
options.add(new SelectOption(time,'label2'));
if(time== 'time2')
options.add(new SelectOption(time,'label3'));
if(time== 'time3')
options.add(new SelectOption(time,'label4'));
}
return options;
}
In the below code, I am mapping
label1 to time1,
label2 to time2,
label3 to time2,
label4 to time3
All these are the picklist values in the field time__c. Now i want
1)label2 to be mapped to 'time2'(which is done) and also to 'reason2' picklist value of reason__c field.
2)label3 to be mapped to 'time2' of time__c field and 'reason3' of reason__C field.
Anyone Please suggest me how can I achieve this.
public List<SelectOption> getTimeOptions()
{
List<SelectOption> options = new List<SelectOption>();
List<String> times= this.getDynamicPicklistValues('Intake__c', 'time__c');
// List<String> reasonTypes = this.getDynamicPicklistValues('Intake__c', 'Reason__c');
for (String time: times)
{
if(time== 'time1')
options.add(new SelectOption(time,'label1'));
if(time== 'time2')
options.add(new SelectOption(time,'label2'));
if(time== 'time2')
options.add(new SelectOption(time,'label3'));
if(time== 'time3')
options.add(new SelectOption(time,'label4'));
}
return options;
}
Then, call getTimeOptions() and getReasonOptions() separately.
If you need to return both Reason and Time options within the same function, then you need to change the return type 'List<SelectOption>' to either a 'Map<String, <List<SelectionOption>>>' where the key would be either 'Time' or 'Reason', for example, or a 'List<List<SelectionOption>>' and add the Time and Reason options list to it.
<apex:selectRadio styleClass="FeedTypeRadio" value="{!Intake__cTime_c}" layout="pageDirection" label="" required="false"> <apex:selectOptions value="{!TimeOptions}" />
</apex:selectRadio>
If I prefer to use List<List<SelectionOption>> as you said, Whether I need to change anything in my vf page?.Can you please provide me a sample to use List<List<SelectionOption>> type in my method.