Always use a custom renderer for a specific field

Thanks for all the help, J. You’re awesome.

I realized that I only really need to override the renderer in edit scenarios, so I ended up with this:

&#47;&#47; Get references to our original picklist field renderers var picklistRenderers = skuid&#46;ui&#46;fieldRenderers&#46;PICKLIST;&nbsp;<br /> var oPickEdit = picklistRenderers&#46;edit;<br /> &#47;&#47;Object as switch statement - stores field API names and corresponding snippet names<br /> var globalPickFields = {<br /> 'Case_Type__c': 'renderCaseTypes',<br /> 'Primary_Phone_Type__c': 'renderPhoneTypes',<br /> &#46;&#46;&#46;Lots more options here&#46;&#46;&#46;<br /> 'Referral_Source__c': 'renderReferralSources',<br /> 'UPT_Results__c': 'renderPregnancyTestResults'<br /> };<br /> &#47;&#47; Override Skuid's standard edit Picklist field renderers to call our custom renderer<br /> picklistRenderers&#46;edit = function(field,value){<br />&nbsp; &nbsp; &nbsp; &nbsp;&#47;&#47; If the field is one of the global picklist fields, run the snippet for it<br /> if (globalPickFields[field&#46;id]){<br /> &#47;&#47;Use a custom renderer<br /> skuid&#46;snippet&#46;getSnippet(globalPickFields[field&#46;id])(field,value);<br /> } else {<br /> &#47;&#47;Use the standard renderer<br /> oPickEdit&#46;apply(this,arguments);<br /> &nbsp; }<br />&nbsp; &nbsp;};


And it works!
All of the custom renderer snippets are in the same inline javascript, so they have access to the standard renderer through the oPickEdit variable. As an example, I’m accessing it like so:

'renderReferralSources': function (field, value) {<br />&nbsp; if (!picklistRows) getPicklistRows();<br /> var filteredList = picklistRows&#46;filter(function(row){<br /> return row&#46;Picklist__c === 'Referral Sources';<br /> });<br /> &nbsp; &nbsp;var picklistEntries = [];<br /> &nbsp; &nbsp;<br /> &nbsp; &nbsp;$&#46;each(filteredList,function(i,row){<br /> &nbsp; &nbsp; if (row&#46;Default__c) {<br /> &nbsp; &nbsp; picklistEntries&#46;unshift(<br /> &nbsp; &nbsp; { value: row&#46;Picklist_Value__c, label: row&#46;Picklist_Value__c, defaultValue: true, active: true }<br /> &nbsp; &nbsp; );<br /> &nbsp; &nbsp; } else {<br /> &nbsp; &nbsp; picklistEntries&#46;push(<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ value: row&#46;Picklist_Value__c, label: row&#46;Picklist_Value__c, defaultValue: false, active: true }<br /> &nbsp; &nbsp; );<br /> &nbsp; &nbsp; }<br /> &nbsp; &nbsp;});<br /> &nbsp; &nbsp;field&#46;metadata&#46;picklistEntries = picklistEntries;<br /> &nbsp; &nbsp;if (field&#46;mode === 'edit') {<br /> oPickEdit&#46;apply(this,arguments);<br /> } else &nbsp;{<br /> picklistRenderers[field&#46;mode](field,value);<br /> }<br />}


We have an object which stores custom pickstlist values for certain picklists, each value on its own row. This allows a high degree of picklist customization by users with the appropriate permissions through a skuid interface. Basically, we’re using skuid to replicate the “Picklists” metadata that’s in beta for SFDC right now, except we’re allowing ‘administrator’ type users to customize the ‘metadata’ for the picklist values through the skuid ui without touching the salesforce setup back end.


Thanks again for your help!