/
5.21.4.2.1 - Custom Messages Within Cases

5.21.4.2.1 - Custom Messages Within Cases

This example will demonstrate a script that will display a custom message in a case depending on the value of a specified field.

This code can be copied and used in your own system, however, it must be edited in order to identify your particular fields and values and to display your own custom messages.

Script

 

Custom Messages Within Cases
// If you are adapting this script for use on your own system, "Customer Rating" should be changed to the name or ID of your own field.
$.get('/api/case/' + caseid + '/data?getValues=Custom.CustomerRating', function( data ) {
	
var value = data.data.customFields[0].value;

// The value that triggers the script should be edited to one that is relevant to your chosen field	
if (value < 50){
// You can specify the message you want to display when the criteria are satisfied here by editing the existing message
		$('#scriptingTarget').html('<div class="alert alert-danger"><i class="icon-info-sign"></i> This Customer has a negative rating</div>');
// The "else" function signifies that what follows is the message that will be displayed if the criteria are not met
	} else {
// You can edit the format of your message by changing "alert-success" to another formatting option
		$('#scriptingTarget').html('<div class="alert alert-success"><i class="icon-info-sign"></i> This Customer has a positive rating</div>');
	}
});

 

This code block contains a script that will display a different message depending on the value of a "customer rating" field. If the value is below 50 then the user will be presented with a warning that the customer has a poor reputation, if it is above 50 then a prompt will remind the user that the customer has a good reputation. 

The following section displays the messages that will be displayed if the value of the field does or does not fulfill your specified criteria.

 

If the value is over 50

 

 

If the value of the "Customer Rating" field is over 50, then a message informing the user of the customers good reputation will be displayed:

 

 

 

If the value is under 50

 

 

When the value of the field is changed to a number below 50, an alternate message that warns the user of the customers bad reputation will be displayed: