is it possible to render a picklist field in a field editor as multiPicklist?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
The use case here being that I don't actually want to save the record which contains the picklist - I am just using it to retrieve multiple values which the user has chosen from the picklist field, and then use a snippet to stick those values into a condition on another model, and run a query.

So really its just a simple picklist field in a field editor, but I want it to render as a multipicklist...

Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, this is doable by using the following Custom Field Renderer Snippet for the picklist field:

var field = arguments[0],
   value = skuid.utils.decodeHTML(arguments[1]);
skuid.ui.fieldRenderers.MULTIPICKLIST[field.mode](field,value);
Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb
works perfectly. Thanks Zach.
Photo of TJ

TJ

  • 952 Points 500 badge 2x thumb
Can I display this rendered Multiselect picklist in 'Checkboxes' format? Like the same way Skuid displays for multiselect picklist when we select 'checkboxes' as field renderer.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, use this instead:

var field = arguments[0],
   value = skuid.utils.decodeHTML(arguments[1]);
field.options.type = "CHECKBOXES";
skuid.ui.fieldRenderers.MULTIPICKLIST[field.mode](field,value);
field.options.type = "CUSTOM";
Photo of Gary

Gary

  • 1,518 Points 1k badge 2x thumb
Thank you Zach and OP, you just saved me a few difficult hours :)
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
I am having trouble in rendering a auto complete field as multi select. Can anybody help?
Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb
Hi Sayan, I'm assuming your autocomplete field is a lookup field to another object - how many records does the lookup object contain? (ie - there are limits to how many values a picklist can contain). 

Can you give us some more info and post a screenshot of what you need to do?
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
I have a field called Property on case that is lookup to Product. While creating case record i want users to be able to select more than one Property.
Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb
A lookup record can only contain a relationship to one other record - so you won't be able to select multiple Products for that one case. If your users will only ever need to select 2 or 3 records, then you could create another couple of lookup fields on the Case object.

But if your users might want to select 'many' related products, then you will need to look at building a Junction object between Case and Product - check out the documentation here on a 'many to many' relationship. This would mean that rather than having a 'field' called Property, you want to create a new 'Custom Object' called Property, with a master-detail lookup to Case, and another Master-detail to Product.
Photo of Vivek Gupta

Vivek Gupta

  • 378 Points 250 badge 2x thumb
How can we access the multiselect picklist values and label seperately. As accessing the field always returns value, if i need the label at somepoint how do we do that?