Client Script that Search if a field contains a certain string

jxa7987
Tera Expert

Hi,

I am making an onSubmit Script that will warn the submitter if the ticket contains the word "child".
Below is my script.. But it doesn't work.. Please help which operator/ script should I use that will search if there is a "child" on the short description. Thanks,

function onSubmit() {
//will prompt the submitter if ticket has a Child

var child = short_description.indexOf("[child]") > -1;

if ((child == true ) && (priority == 1)){
confirm ('Warning: You seem to be classifying a child ticket as a Prio1. That is probably not correct. Please click Cancel to correct or OK to proceed (not advised)');
}

}

2 REPLIES 2

Mark Stanger
Giga Sage



function onSubmit() {
//will prompt the submitter if ticket has a Child
var child = g_form.getValue('short_description').indexOf("child") > -1;
var priority = g_form.getValue('priority');

if ((child == true ) && (priority == 1)){
confirm ('Warning: You seem to be classifying a child ticket as a Prio1. That is probably not correct. Please click Cancel to correct or OK to proceed (not advised)');
}
}


jxa7987
Tera Expert

It now works! My apologize as I am really new to scripting.. Thanks Mark!