Skip to main content
Inspiring
Apr 20, 2022 12:40 AM UTC
Question

dropdown

Hi,

I have a dropdownfield in the edit screen. Initially when I open existing record, by that time this field will not having any data and based on the user search in another field, this dropdown will load the data.

When I try to set ChoiceValue to null it is not accepting. Can some one guide me how to handle this when there is no data in initial load.

Thanks

ERROR:

8 replies

danny.verb
Employee
Apr 20, 2022 3:38 AM UTC

The choice labels and choice values must have data. The dropdown component automatically displays the label for the 'value' field if that value appears in the choiceValues parameter. Try removing the if statement.

Inspiring
Apr 20, 2022 10:27 AM UTC

Thanks for your suggestion.

richardm900458
Inspiring
Apr 20, 2022 5:29 AM UTC

"by that time this field will not having any data and based on the user search in another field"
Then its not a good interface design. Try to use a showWhen condition or unfiltered values as choicevalues or choicelabel. For the showWhen condition you can set a isnull evaluation - show when its not null.

Inspiring
Apr 20, 2022 10:27 AM UTC

Thanks for your suggestion.

abhayd3663
Brainy
Feb 21, 2023 5:04 AM UTC

Simplest way to handle nulls in dropdownField, is to provide some value to the placeholder parameter, look at the following it works!!!

a!dropdownField(
placeholder: "-- Select Some Options -- "
)

richardm900458
Inspiring
Feb 22, 2023 1:00 PM UTC

Which is not helping for a choicevalue array element which is a null value. :)

paoloc0002
Participating Frequently
Feb 22, 2023 3:30 PM UTC

Hello, 

For the component, Choice Labels must be present, and an equal number of values must coincide with those labels. If you do not have data on load, the component will throw this error. Therefore, I would suggest utilizing the visibility parameter "showWhen" to check if you have data for these fields, if you do - then you can display the component. If you do not, then you should hide the component.