Lock a field based on picklist options

Lock a field based on picklist options

Hi,

I have a picklist field that I want non-Admins not to be able to change to/from 3 of the options.

I currently have the current code which is showing me the Alert and locking the field but still changing the selection.

I'm a newbie with deluge so any help is appreciated. Thank you.

var userId = $Crm.user.id;
var usrData = ZDK.Apps.CRM.Users.fetchById(userId);
var profileName = usrData.profile.name;
var currentStage = ZDK.Page.getField("Account_Stage");
var newStage = currentStage.getValue ();

var restrictedStages = ["Customer", "Former Customer", "Former Trial Customer"];

if (profileName != "Administrator") {
if (
(restrictedStages.includes(currentStage) && restrictedStages.includes(newStage)) ||
(!restrictedStages.includes(currentStage) && restrictedStages.includes(newStage)) ||
(restrictedStages.includes(currentStage) && !restrictedStages.includes(newStage))
) {
ZDK.Page.getField("Account_Stage").setReadOnly(true);
ZDK.Client.showAlert("Can't manually edit this field. Please reach out to an admin.");
}
}