0

I have picklist field contains Zero,First,Second,Third,Four and need to update the Counter field if the user select from First to beyond.Example it will update if user select Zero to First.It Wont update the field if user select First to Zero.Same goes if user select First to Third but not Third to Second or Third to First.

The scenario will be Zero --> First --> Continuously but not backward.I am thinking doing this using Apex Trigger and using List to store value but any logic to implement this easily.

4
  • If you don't have many values, formula field might work. Commented Feb 29, 2016 at 12:42
  • Formula field?How it detect that the value must be forward not backward?
    – unidha
    Commented Feb 29, 2016 at 12:54
  • There is a formula function for detecting the previous value of a field. Commented Feb 29, 2016 at 13:00
  • Yeah that's true I've forgot that we can't use priorvalue in formulas. Then that trigger is the only way. Commented Feb 29, 2016 at 13:00

1 Answer 1

2

You can easily do it with apex.

I would create a Map<String, Integer> to 'translate' text to integers and then just compare these integers(for example:

if (theMap.get(oldValue) < theMap.get(newValue)) {
    // increment your counter
}

) to see if the new value is greater than the previous one(and how much bigger if needed)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .