Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
languagejs
titleUpdate Case Information
linenumberstrue
// The first line specifies the field you want the script to depend on
[Changed.CustomField("val_a"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("val_a6364").NewValueAsNumber <= 50) {
		
// The format for updating case information is "Service.UpdateCaseInfo("statusField Name", "openValue");
		"
        Service.AddMessageUpdateCaseInfo("Case info successfully updatedstatus", "notify-successclose");
		        Service.AddMessage("Case info successfully updated", "dialognotify-success", "Success");
        return true;
// The section below specifies the alternative value if the custom field holds a value above 50
    } else if (50 < Changed.CustomField("val_a6364").NewValueAsNumber < 100) {
		
        Service.UpdateCaseInfo("milestone.1142status", "1.1.2015open");
		
        Service.AddMessage("Case info successfully updated", "notify-success");
		Service.AddMessage("Case info successfully updated", "dialog-success", "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"); 		Service.AddMessage("An error occurred while updating case info", "dialognotify-error", "Error");
        return false;
    }
}

//Service.UpdateCaseInfo(string fieldName, string newValue)