Multiselect picklist - How do we access label ?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have created custom renderer to display a dynamic values in a multiselect picklist ui only field.

params.options.type = "CHECKBOXES";   
params.options.type = "CUSTOM";    
picklistEntries = [];
picklistEntries.push({ value: '0', label: 'AAA', defaultValue: false, active: true });
picklistEntries.push({ value: '1', label: 'BBB', defaultValue: false, active: true });
picklistEntries.push({ value: '2', label: 'CCC', defaultValue: false, active: true });
params.metadata.picklistEntries = picklistEntries;

skuid.ui.fieldRenderers.MULTIPICKLIST.edit(params,value);

Now at some point if i need to access the label (AAA, BBB..) for this field, how can this be achieved as accessing the field is always returning the value.
Photo of Vivek Gupta

Vivek Gupta

  • 378 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
The metadata label for the database Field itself is available through field.metadata.label
Photo of Vivek Gupta

Vivek Gupta

  • 378 Points 250 badge 2x thumb
Zach,
The requirement is to get the label,value pair of the multiselect picklist. I am able to get the value by using the field api directly but to access the label of label,value pair is something which is required.
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb
Hi Vivek,

There are two ways I know of to get that metadata.
Either way you would have to check what data has been selected and match them with the metadata (since its a multipicklist you need to split the values by ";").

1: You could add a change listener on the field (params.element) and access the picklist entries using "params.metadata.picklistEntries" (you can do that in the same snippet as your field renderer)
2: You could also access the metadata (in another snippet) using "model.fields[x].picklistEntries" where "model" is your model and "x" is the index of the field in the fields array

Cheers