disabled the “delete” button from the related list on all Demands once the Demand has left the Draft

r2024
Tera Contributor

hello everyone,

I want to disabled the “delete” button from the related list on all Demands once the Demand has left the Draft state. That way the demand does not get deleted accidently. I know that I need to change it in the Condition field, but when I do it the “delete’ button is gone. This is what I put in the condition field:

current.isValidRecord() && current.canDelete() && current.getState() =='Delete'

 

What is the correct way of writing this?

1 REPLY 1

Weird
Mega Sage

current.getState() came from where? I don't think that's correct (I might be wrong). If you're checking the current state then just say "current.state == "delete". Here delete would be the actual value of the choice and not the display value you see on the form. If you use functions that don't exists your script will fail and the button will be hidden always.

Also, It's pretty worrysome if some records get deleted accidentally. You'd probably want to make sure records are not deleted just because by anyone. Whoever deletes them must know what they're doing.