forked from ServiceNowDevProgram/code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
20 lines (20 loc) · 829 Bytes
/
script.js
File metadata and controls
20 lines (20 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
Type: onChnage
Table: sys_template
Field: Template
*/
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('table') == 'incident') { // table on which sys_template is being created.
var fields = ['active', 'comments']; // array of fields to be restricted while template creation.
for (var i = 0; i < fields.length; i++) {
if (newValue.indexOf(fields[i]) > -1) {
alert("You Cannot Add " + fields[i]); // alert if user selects the restricted field.
var qry = newValue.split(fields[i]);
g_form.setValue('template', qry[0] + 'EQ'); // set the template value to previous values (oldValue does not work in this case).
}
}
}
}