...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// The first line specifies the field you want the script to depend on
[Changed.CustomField(6364).Changed]
function on_save() {
// The section below specifies a case field and the value it should be changed to if
// the custom field holds a value below 50
if (Changed.CustomField("6364").NewValueAsNumber <= 50) {
// The format for updating case information is "Service.UpdateCaseInfo("Field Name", "Value")"
Service.UpdateCaseInfo("status", "close");
Service.AddMessage("Case info successfully updated", "notify-success");
//"return true" means that the new data will be stored in your system while "return false" signifies that the new data will not be saved
return true;
// The section below specifies the alternative value if the custom field holds a value above 50
} else if (50 < Changed.CustomField("6364").NewValueAsNumber < 100) {
Service.UpdateCaseInfo("status", "open");
Service.AddMessage("Case info successfully updated", "notify-success");
return true;
// The script below triggers an error message if neither of the conditions above are satisfied.
} else {
Service.AddMessage("An error occurred while updating case info", "notify-error");
return false;
}
}
|
...