Skip to main content
witoldw0001
January 16, 2023
Question

Dropdown choiceValues and values

  • January 16, 2023
  • 8 replies
  • 0 views

How to effectively prevent UI evaluation errors when choiceValues change? 

In my project, we are commonly using a table holding reference data to be displayed in dropdown fields.

The problem is, whenever these values change, the dropdowns get updated, but if a value has been removed or edited, but previously saved to the database, now we get a UI evaluation error saying that the value is not present in the choiceValues - which is understandable, of course.

But how can we effectively guard against this sort of behavior? After an update like this, we usually face a billion errors when users (or developers) bring up an old record or old task, which had a value saved that is no longer present in a dropdown. Is there a good preventive measure for this sort of cases?

8 replies

harshitb6843
January 16, 2023

I would suggest curing this problem in a proper way where you just store the ID and not text (label) of the value in the DB. Now it doesn't matter how many times you change the value (label) because the ID remains the same and hence dropdowns will always display the newest value. 

Now a way to fix it with the text data is to check if the data is present in the choiceValues and if yes, then only show it in the value else show null. 

That way, whenever a value changes, you will a blank dropdown. 

witoldw0001
January 16, 2023

Indeed, this would be a proper way of fixing this problem, though for an old project it seems a bit invasive.

"Now a way to fix it with the text data is to check if the data is present in the choiceValues and if yes, then only show it in the value else show null."

I guess this would be a way to prevent the evaluation error, but I think it would be up for debate to decide whether a blank dropdown is even worse than evaluation errors, since they are easier to miss, and errors usually force quick fixes. Am I reasoning correcly?

harshitb6843
January 16, 2023

But I can't think of a third way that solves our problem. There is a lengthy way, which includes updating the values in the DB everytime you change the lookup values. 

stewart.burchell
January 18, 2023
  1. Never remove values from the database. Use a Boolean flag (typically labelled 'isActive') to indicate whether the value is currently available for use
  2. Always store the key to the value, not the value itself. Keys are immutable and, if you follow the previous guidance, always available
  3. For new Cases you can exclude those values in the Ref Data that have 'isActive' marked as 'false'. Cases that previously used that value can have that value (and its key) appended to the currently active list to prevent UI failures.
  4. Have very clear rules that determine if a Case that has a value that has an inactive value selected and is now being edited can continue to use that value or that it needs to be replaced with a currently active value. This will be driven by the business requirements. 
davel001150
January 18, 2023

Good stuff, and good to spell out more explicitly.