How to prevent user to change status back to old value?

Hi, I have a column “Order Status” which is ENUM [Pending,Started,Finished,Cancelled], and
I wish to block the user to save record
when user
change from Pending to Finished, or
change from Started Back to Pending, or
change from Finished to Cancelled or
change from Cancelled to Finished or
change from Cancelled to Started or
change from Cancelled to Pending

Can any one help to advice me please, thanks.

Hi @kalmen_chia

Welcome to the community.

You may wish to use the Suggested Value field, with a SWITCH expression.
Here is the documentation:

Your expression you are looking for could be something like:

SWITCH([Order Status],
   "Pending", LIST("Finished"),
   "Started Back", LIST("Pending"),
   "Finished ", LIST("Cancelled "),
   LIST("Finished","Started","Pending")
)

Please note that the last input is a default value.

Let us know if that works for you !

2 Likes

Hi Aurelien,

thanks for the advice and idea,

what works for me is as follow,
SWITCH([Order Status],
“Pending”, LIST(“Finished”),
“Started Back”, LIST(“Pending”),
"Finished ", LIST("Cancelled "),
LIST(“Finished”,“Started”,“Pending”)
)
when is cancelled, they can’t switch it back and
when is finished, they can’t switch it back.

solved.

3 Likes

Valid If instead:

(
  LIST([Order Status])
  + SWITCH(
    [Order Status],
    "Pending",
      LIST("Started", "Cancelled"),
    "Started",
      LIST("Finished", "Cancelled"),
    "Finished",
      LIST(),
    "Cancelled",
      LIST("Finished"),
    LIST("Pending", "Started", "Finished", "Cancelled"),
  )
  - LIST("")
)
2 Likes

Hi @Steve,

Thanks for your correction.

That distinction isn’t very clear for me: in which case is it more pertinent to use the Suggested_value, in which case it is the Valid_if ?

2 Likes

Suggested values produces a dropdown from which the user may choose, or the user may enter another value. Suggested values does not itself prevent the user from entering an arbitrary value. To prevent the user from entering some other value, you must use both Suggested values and Valid If, or just Valid If.

2 Likes

Awesome, thanks for that :+1:

2 Likes

Thanks all for the help. :smiley:

2 Likes