Custom picklist renderer when option source is a model

Ryan, You should be able to do this with a snippet, a model (to select the values that you want in the drop down which it sounds like you’ve already built this), and a custom field renderer. The solution should be similar to the one outlined in our community post on creating a drop down list from a custom setting. In any case, here’s what a snippet like this might look like using a custom reference field of Contact__c and a model called “Contacts”:

var field = arguments[0]; var value = arguments[1]; if (field.mode === 'edit') { // Build the Options for the PICKLIST var customOpts = []; skuid.$.each(skuid.model.getModel('Contacts').getRows(), function(i,row) { customOpts.push({ value : row.Id, // Will be stored in target object label : row.Name // Will display in the PICKLIST }); }); // Render the options as a PICKLIST var customSelect = skuid.ui.renderers.PICKLIST.edit({ entries : customOpts, required : false, value : value }).change(function() { console.log(skuid.$(this)); // Update the row in the target object field.model.updateRow(field.row,'Contact__c',skuid.$(this).val()); }); // Append the PICKLIST to the DOM element field.element.append(customSelect); } else { // If the mode is anything other than edit, display the field as Text skuid.ui.fieldRenderers.TEXT[field.mode](field,field.model.getFieldValue(field.row,'Contact__r.Name')); }

The added complication is making sure that the same row isn’t selected twice. You could enforce this at the model condition level (using our new “not in” operator for subquery conditions, for instance) and at the DB level with a trigger, but this wouldn’t keep track of which rows have been selected and unselected while you are in edit mode. You would have to write some pretty complicated JavaScript to accomplish this, so it may be more trouble than it’s worth. Does this help you out?