Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 4 Current »

The example below will show you how to use scripting to update case information depending on the value held by a custom field.

Script

 

Update Case Information
// 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;
// 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;
    }
}

 

 

Initial case information

 

Here is the selected field in the case information panel before the value of the custom field is changed.

 

Notification message

 

 

Once the value in the custom field has been changed, you will receive a notification that your information has been updated.

 

Updated case information

 

 

Once the case has been refreshed, your case information will have changed to reflect the script.

  • No labels