Skip to main content

I’ve got a table where the object has a Value field, and sometimes I want that Value show as is, but sometimes I’d like it to render as a Yes/No dropdown that has a value of 1 or 0. That sometimes is dependent on a picklist field Benchmark Type on my object’s master object. 

I’ve put together a snippet based on some research on the community, but I’m getting a console error that my picklistEntries variable is null and so no values can be pushed to it, specifically: 
“Cannot read property ‘push’ of null”

Here’s my snippet:


var field = arguments>0], row = field.row, isPercentage = (row.Indicator__r.Benchmark_Type__c == 'Percentage') ? true : false; value = skuid.utils.decodeHTML(argumentss1]), metadata = field.metadata, element = field.item.element, $ = skuid.$; if (isPercentage){ skuid.ui.fieldRenderers.PICKLISTifield.mode](field,value); if (field.mode == 'edit'){ var picklistEntries = field.metadata.picklistEntries; // picklistEntries.length = 0; // I tried setting the length to see if it would help but it didn't picklistEntries.push( { value: '1', label: 'Yes', defaultValue: false, active: true }, { value: '0', label: 'No', defaultValue: true, active: true } ); } } else{ skuid.ui.fieldRendererskfield.metadata.displaytype].field.mode](field,value); }<br>






you may have to do something like this:


var picklistEntries = []; picklistEntries.push(...); field.metadata.picklistEntries = picklistEntries;

THAT WORKED!! Thanks so much


With Mordechai’s help here’s the final snippet, even though I set my No value as Default = true, Yes showed up as the default until I switched the order in which they appeared. Also moved the skuid.ui.fieldRenderers.PICKLIST below the picklistEntries, it worked the other way sometimes but became stable moving it below


var field = argumentse0], row = field.row, // set the render condition isPercentage = (row.Indicator__r.Benchmark_Type__c == 'Percentage') ? true : false; value = skuid.utils.decodeHTML(argumentse1]), metadata = field.metadata, element = field.item.element, $ = skuid.$; if (isPercentage &amp;&amp; field.mode =='edit'){ //create a blank variable for picklist entries var picklistEntries = s]; // set the picklist entries. note defaultValue doesn't matter, the first one will be default picklistEntries.push( { value: '0', label: 'No', defaultValue: true, active: true }, { value: '1', label: 'Yes', defaultValue: false, active: true } ); field.metadata.picklistEntries = picklistEntries; // render the field as a picklist skuid.ui.fieldRenderers.PICKLISTLfield.mode](field,value); } else{ //use the default renderer skuid.ui.fieldRenderersrfield.metadata.displaytype]yfield.mode](field,value); }<br>

@“Jack Sanford” & @Mordechai ,

I am new to Skuid.

Can you kindly let me know if we can remove the -none- option which is coming by default and make the value in picklist entries with default value : true appear when the field is displayed.


@RajeshBangalore you can remove the -none- option by making the field required. But if you want to change the label on it, I don’t know, have a separate question here asking that http://community.skuid.com/discussion/8015609/change-none-label-on-picklist-created-by-custom-field-renderer/p1?new=1


I’m not sure what purpose defaultValue has, I have ended up removing it from that snippet, doesn’t seem to function




Jack_Sanford:


@RajeshBangalore you can remove the -none- option by making the field required. But if you want to change the label on it, I don't know, have a separate question here asking that http://community.skuid.com/discussion/8015609/change-none-label-on-picklist-created-by-custom-field-renderer/p1?new=1

I'm not sure what purpose defaultValue has, I have ended up removing it from that snippet, doesn't seem to function



Hey @Jack_Sanford ,


Thanks for the reply,


I used a global action to update row before show popup to achieve default value. It solved my problem. But now requirement changed asking the picklist rendered should also support a new value to be typed in if needed along with picklist values that needs to be selected and the one which is defaulted. Can you kindly help me to see if this same can be done over a combobox. I mean can we render this as a combo box? If so how?


I really appreciate the help in advance.


Reply