UI Only PickList Custom Field Renderer Snippet Stopped working

  • 1
  • Problem
  • Updated 2 years ago
  • In Progress
I have a UI-Only picklist field on an object that up until a week ago was being populated by a custom field renderer snippet.  Circumstantially, the snippet appears to have to have stopped working after the Rockaway 8.11 point release was applied on 6/8/2016.

The issue seems to be that the UI-only picklist field no longer has a picklistEntries member in the field metadata.  Here is the contents of the snippet:


var params = arguments[0],	$ = skuid.$;
var field = arguments[0];
console.log(field);
var picklistEntries = field.metadata.picklistEntries;
picklistEntries.length = 0;

skuid.$.each(skuid.model.getModel('Periods').getRows(), function(i,row) {
    
    var isDefaultValue = false;
    
    if(i===0){
        isDefaultValue=true;
        var mod = skuid.model.getModel('AccountingPeriodSignOffs');
        var cond = mod.getConditionByName('Period_Code__c');
        mod.setCondition(cond,row.maxPeriodCodec);
        mod.updateData();
    }
    
    picklistEntries.push({value: row.maxPeriodCodec, label: row.maxPeriodCodec, defaultValue: isDefaultValue, active: true});
    
});
var value = skuid.utils.decodeHTML(picklistEntries[0].value);
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);


The error is: "Uncaught TypeError: Cannot set property 'length' of undefined" which is thrown at the "picklistEntries.length = 0;" line, suggesting that field.metadata.picklistEntries is undefined

Sure enough, when I look at the output of the console.log(field) I see that there is no longer "picklistEntries" member:


Can anyone recommend a fix or workaround?
Photo of Matt Leedham

Matt Leedham

  • 202 Points 100 badge 2x thumb
  • anxious yet hopeful

Posted 2 years ago

  • 1
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,220 Points 5k badge 2x thumb
Matt~

We are unable to reproduce the error you are seeing. Can you create a page using standard Salesforce objects that mirrors the functionality you want on this page? If the problem persists, paste the XML here for us to take a look at.

Thanks!
Karen
Photo of Matt Leedham

Matt Leedham

  • 202 Points 100 badge 2x thumb
Hi Karen,

No problem - I was just able to repro using the "Contact" Salesforce object.  XML is below:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">    <models>
        <model id="RecentContacts" limit="5" query="true" createrowifnonefound="false" adapter="salesforce" type="" sobject="Contact" orderby="CreatedDate DESC">
            <fields>
                <field id="CreatedDate"/>
                <field id="Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="Filter" limit="1" query="true" createrowifnonefound="true" adapter="salesforce" type="" sobject="Contact">
            <fields>
                <field id="NameFilter" uionly="true" displaytype="PICKLIST" label="Filter"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Filter" buttonposition="" uniqueid="sk-1M0KI5-162" mode="edit">
            <columns>
                <column width="50%">
                    <sections>
                        <section title="Section A" collapsible="no" showheader="false">
                            <fields>
                                <field id="NameFilter" valuehalign="right" type="CUSTOM" snippet="SetPickListValues" required="true"/>
                            </fields>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="RecentContacts" buttonposition="" mode="read" uniqueid="sk-1L-pDV-111">
            <fields>
                <field id="Name"/>
                <field id="CreatedDate"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript>
            <jsitem location="inlinesnippet" name="SetPickListValues" cachelocation="false">var params = arguments[0],
$ = skuid.$;

var field = arguments[0];

console.log(field);
/**/
var picklistEntries = field.metadata.picklistEntries;

picklistEntries.length = 0;

skuid.$.each(skuid.model.getModel('RecentContacts').getRows(), function(i,row) {
    
    var isDefaultValue = false;
    
    if(i===0){
        isDefaultValue=true;
    }
    
    console.log(row.Name);
    
    picklistEntries.push({value: row.Name, label: row.Name, defaultValue: isDefaultValue, active: true});
    
});

var value = skuid.utils.decodeHTML(picklistEntries[0].value);

skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
/**/
/*
skuid.$.each(skuid.model.getModel('RecentContacts').getRows(), function(i,row) {
    
    var isDefaultValue = false;
    
    if(i===0){
        isDefaultValue=true;
    }
    
    console.log(row.Name);
    
});
*/</jsitem>
        </javascript>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>


Thanks,

-Matt
(Edited)
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Hi Matt, Is your ui-only filter field empty or does it have picklist entries? The picklistEntries field will not show up in the object metadata when the list is empty.

Thanks,

Amy