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.");
}
}