Picklist entries custom renderer not working

  • 1
  • Question
  • Updated 2 years ago
Does anyone see anything wrong with this?
Renderer isn't working. No console errors other than 'Refused to set unsafe header agent'

Seems like somehow the field metadata isn't getting overwritten? I'm just getting the standard values for the picklist. I've watched the rendering in the console, and the picklistEntries array is definitely getting populated with the right values.

'renderPRLLists': function(field,value){	value = skuid.utils.decodeHTML(value);
var listModel = skuid.$M('CreatePRL_Lists'),
picklistEntries = [];
$.each(listModel.getRows(),function(i,row) {
picklistEntries.push(
       { value: row.Name, label: row.Name, defaultValue: false, active: true }
);
});  
field.metadata.picklistEntries = picklistEntries;
skuid.ui.fieldRenderers.MULTIPICKLIST.edit(field,value);
field.model.updateRow(field.row, field.id, value, {initiatorId: field._GUID});
}
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
Hey Matt -

A few things:

1) I'm assuming you've done this, but have you debugged to make sure that the renderer is getting called and inspected the metadata.picklistEntries before/after establishing the new value?

2) Is there a reason you are calling updateRow in the last line?  The value of the field should already be set by the time the renderer is called so I'm not seeing a reason that you need to update the field value?

3) What version of Skuid are you running?

4) Can you try changing the code to use a hardcoded list of values instead of from a model just to rule out a 'data' issue with the model data itself?  For example:

var picklistEntries = [];
picklistEntries.push({ value: '0', label: 'AAA', defaultValue: false, active: true });
picklistEntries.push({ value: '1', label: 'BBB', defaultValue: false, active: true });
picklistEntries.push({ value: '2', label: 'CCC', defaultValue: false, active: true });
field.metadata.picklistEntries = picklistEntries;
(Edited)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Good ideas, Barry.
1) Yes.
2) No idea what I was thinking there.
3). 8.10
4)  I'll do some more digging.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
Sounds good Matt, just lemme know.  Btw, I threw together a quick sample with 8.10 and it's working as expected for me so there is hope :)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
The crazy thing is, it's running just fine in our dev org. But it's not working in production. Any thoughts on what the difference might be? The only difference in the code is that I ran it through uglify.
(Edited)
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
That is rather strange.  Couple of questions/thoughts:

1) 8.10 in both Dev & Prod?
2) Dev is Summer '16 or Spring '16?  If Dev is Summer '16, do you you have a Spring '16 SBX that you can test against? 
3) For some reason, I remember seeing a thread a while back where Zach mentioned something about overriding picklist values and it not respecting the change and there was a reason.  Unfortunately, I can't remember the reason nor can I find the thread right now.  I might be remembering incorrectly but for some reason, that memory is sticking out in my head right now. 

Zach - Any thoughts?  Maybe I'm not remembering correctly?
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Are there record types or picklist dependencies that are different in the two orgs? Skuid applies extra logic for picklists that have record type dependencies and may be throwing out your changes. I can't dive into the code on this right now, but it might be worth checking.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
Thanks Ben, that's what I remember seeing!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ah, that's right. Thanks, Ben & Barry. I think we have some legacy record types in production that I need to remove. They're probably at fault.