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.

  • If you don't have many values, formula field might work. – Oles Malkov Feb 29 '16 at 12:42
  • Formula field?How it detect that the value must be forward not backward? – unidha Feb 29 '16 at 12:54
  • There is a formula function for detecting the previous value of a field. – Davin Casey Feb 29 '16 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. – Oles Malkov Feb 29 '16 at 13:00

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.