How can I get the picklist values for a field for a specific record type in js?

I’ve looked and looked. Can’t find a direct Skuid function to get this.

I would like to create a model based on picklist values in order to create a deck with columns based on picklist values.

Can’t think of a way to do that directly with the possible picklist options themselves, but you could perhaps create an aggregate model of whatever object you’re working with grouped by and ordered by the picklist field. That would give you only the distinct picklist values that actually exist as saved rows in the database. Then you could build the deck based off of that model.

Not sure if this sort of a solution is applicable to your use case, but it’s all I can think of since I’m unaware of a way to pull out the selectable options from the picklist (metadata).

This would work only if there is a record for each possible variation. Likely would work but could be problematic the moment one variation isn’t on a record.

You’d also have the issue of Active / Inactive picklist values. I believe if you somehow find a way to pull the metadata you’d only be getting active values, whereas the database may also include Inactive values and there wouldn’t be a way to tell what is active vs. what is inactive.

Here’s a weird idea, not sure if it would work… (and admittedly this is messy…)

You could create an empty model (create an empty row if none exists) for the object in question and make a “temporary” field editor with a custom rendered picklist field for the picklist, and in the renderer snippet for custom rendered picklist field step through all the possible picklist options then add each of those as a row in your deck’s main model. Then when done with this you can hide the temp field editor from display (unfortunately it needs to be displayed at least once to run through the conditional field renderer)

Here’s some javascript for the custom field renderer that could achieve this. Unfortunately this won’t get the field name, it will get the field value (API value) of the picklist entry. I’m not sure how to get the name ($this.name() maybe, or some other way with some investigation into what details you can pull out of $this?)

var params = arguments[0],
$ = skuid.$;
var field = arguments[0];
var cellElem = field.element;
var row = field.row;
var value = arguments[1];
var m = skuid.model.getModel(‘OurModelOfPicklistOptions’);
skuid.ui.getFieldRenderer(field.metadata.displaytype).edit( field, value );
var select = field.element.find(‘select’);
if (select.length) {
// Get our picklist options
$.each(select.children(‘option’),function(){
var picklistOptionValue = $(this).val();
if (picklistOptionValue != ‘’){
m.createRow({doAppend: true, additionalConditions: [
{field: ‘PicklistOption’, value: picklistOptionValue}
]
});
}
});
}```

Yoo hoo! Skuidypoo! Got a solution for this?

Yo!!!    Found a somewhat janky but viable solution.

  1. Create a model for setting the record type and creating a row. (I used SelectedRecordTypeCaseTypes)
  2. Create a model to store the available picklist options. (I used CaseTypes)
  3. Add a form on the page. (you can set this to never conditionally render)
  4. Set the Id of the form (I used caseTypes) and add only the picklist you'd like values for based on your selected record type.
  5. Set something on your page to set the model record type condition, create a row, and run the following snippet.
var $ = skuid.$, CaseTypes = skuid.$M('CaseTypes'), SelectedRecordTypeCaseTypes = skuid.$M('SelectedRecordTypeCaseTypes'), caseTypes = SelectedRecordTypeCaseTypes.registeredFields.caseTypes__0.childComponents[2].definition.options; $.each(caseTypes, function(){ CaseTypes.createRow({ additionalConditions: [ { field: 'Name', value: this.value} ] }); });
I'm fairly certain this can be adapted for filter use as well.