Skip to content

Commit a64c2a1

Browse files
authored
Create Set_and_Lock_Variable_by_Group
1 parent af88ba1 commit a64c2a1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function onLoad() {
2+
var variableName = 'bypass_approval_reason';
3+
var targetGroupName = 'ServiceNow Support'; // The group authorized to skip this step
4+
var ga = new GlideAjax('UserUtils');
5+
ga.addParam('sysparm_name', 'isMemberOf');
6+
ga.addParam('sysparm_group_name', targetGroupName);
7+
ga.getXMLAnswer(checkAndLockVariable);
8+
function checkAndLockVariable(response) {
9+
var isMember = response;
10+
if (isMember == 'true') {
11+
var message = 'Value set and locked due to your ' + targetGroupName + ' membership.';
12+
var setValue = 'Bypassed by authorized ' + targetGroupName + ' member.';
13+
g_form.setValue(variableName, setValue);
14+
g_form.setReadOnly(variableName, true);
15+
g_form.showFieldMsg(variableName, message, 'info');
16+
} else {
17+
g_form.setReadOnly(variableName, false);
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)