This is an extension of a great post here: https://community.skuid.com/t/how-do-i-render-custom-picklist-values
I’m trying to take the selected values from a multipicklist field and render them as a picklist.
Here’s my custom renderer:
var field = arguments[0], value = skuid.utils.decodeHTML(arguments[1]),<br> $ = skuid.$;<br>console.log('Rendering Session 1');<br>var intakeModel = skuid.$M('BabyMeIntake'),<br> intakeRow = intakeModel.getFirstRow(),<br> interests = intakeModel.getFieldValue(intakeRow,'Learning_Interests__c');<br>if (interests) {<br> var interestsArray = interests.split(';');<br> var picklistEntries = field.metadata.picklistEntries;<br> picklistEntries.length = 0;<br> <br> $.each(interestsArray,function(i,str){<br> picklistEntries.push(<br> { value: str, label: str, defaultValue: false, active: true }<br> );<br> });<br>}<br>if (!value) {<br> value = (interestsArray && interestsArray.length) ? interests[0] : value;<br> field.model.updateRow(field.row, field.id, value, {initiator_id: field._GUID});<br>}<br>console.log('updatedfield:');<br> console.log(field);<br> <br>skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
The problem I’m having is that the picklist still renders all of the entries, despite the fact that the ‘field’ showing up in the console log has the correct shortened list of picklistEntries.
What am I doing wrong?
Also, not sure if this is related, but I’m using a model action when the ‘Learning_Interests__c’ field is updated to render the field editor that has the field with this custom renderer, like so:
skuid.$C('SessionOneFields').render();
That seems to be working, although the rendering logic seems to run more than once each time, for some reason I don’t understand. If I don’t have the model action, the field renderer doesn’t run, but if I have it, it runs multiple times.
?