Dropdown choiceValues and values

Certified Associate Developer

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?

  Discussion posts and replies are publicly visible

Parents
  • 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. 

Reply
  • 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. 

Children
  • 0
    Certified Associate Developer
    in reply to Harshit Bumb (Appyzie)

    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?

  • 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. 

  • 0
    Certified Lead Developer
    in reply to Harshit Bumb (Appyzie)

    That's actually the approach I would take.  If a value gets removed, you should create a script that cycles through all tables that could reference that value and for each of them replace the removed value with something else. 

    If you don't clean your data right away it stays dirty.  If you and all your colleagues leave the project one day, the poor souls who inherited it will never know what those extraneous values were ever supposed to mean, and they won't be able to fix the lavaflow code after you.  You'll never get approval to clean it after you've done this in a separate story, so you have to while you're doing it.

    The secret to tech debt is to try borrowing as little as possible.  You have to pay it back or pay tons of interest.