Skip to main content
Nintex Community Menu Bar
Question

Rendering integer as picklist.

  • July 9, 2024
  • 6 replies
  • 28 views

Forum|alt.badge.img+18

I’m attempting to render a number field as a picklist.

Here’s what I’ve got so far:

var field = arguments[0], value = arguments[1], $ = skuid.$;  

field.metadata.picklistEntries = [
       { value: 30, label: ‘30 minutes’, defaultValue: false, active: true },
       { value: 60, label: ‘60 minutes’, defaultValue: true, active: true }
];
field.metadata.defaultValue = 60;
    skuid.ui.fieldRenderers.PICKLISTfield.mode;
}

It’s working, sort of.

With the defaultValue line I was trying to eliminate the “none” option, but I’m still getting “–None–” by default.
Is there a way to eliminate the --None-- option?

The values are returned as strings. Not sure if there’s a way to change that so that it outputs numbers. If there’s not, I can handle it on the other side with Number().

Thanks!

This topic has been closed for replies.

6 replies

Forum|alt.badge.img+13

Is the field required? You can only eliminate the “–None–” option if the field is NOT required, otherwise it would be impossible for a user to leave the field blank. If the field IS required, then you can eliminate the --None-- option by using the following option:

field.options.addNoneOption = false;

Whenever you’re setting picklist field entries, value needs to be a string, not a number, same thing for for field.metadata.defaultValue.

FYI, the purpose of the defaultValue property on field metadata is to specify a value to insert into this field when creating a new record of the given object– the field.metadata.defaultValue property is not used after a record is first saved. 


Forum|alt.badge.img+18
  • Author
  • July 9, 2024

Zach,

Thanks for the thorough explanation!
My renderer is working, even though I’m giving it numbers instead of strings. The field isn’t required, but it makes sense to make it required (at least in the ui, if not salesforce).


Forum|alt.badge.img+18
  • Author
  • July 9, 2024

One quick additional question:

What does the ‘defaultValue’ in the definition of a picklist entry do (in bold below)?

field.metadata.picklistEntries = [
       { value: 30, label: ‘30 minutes’, defaultValue: false, active: true },
       { value: 60, label: ‘60 minutes’, defaultValue: true, active: true }
];


Forum|alt.badge.img+13

Currently, nothing.


Forum|alt.badge.img+18
  • Author
  • July 9, 2024

ha. ok.


Forum|alt.badge.img+5

OK. So what does “active:true” do?  What happens with “active:false”? 

Doesn’t seem to change anything for me.