Set Assigned To Field Depeand on Assignment Group In Catalog variables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I created two variable name as "Assignments Group" as a reference field and refer it to Group table , and "Assigned To" and refer it to the user table , if there is a single user in the assignment group then the user should set auto in the assigned to field
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
54m ago
Hello @piyushbedre ,
Use the below script include & Client script the achieve the output as per you requirement :
Script Include :
checkSingleUser: function() {
var groupId = this.getParameter('sysparm_group_id');
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', groupId);
grMember.query();
if (grMember.getRowCount() == 1) {
if (grMember.next()) {
var result = {
sys_id: grMember.getValue('user'),
name: grMember.user.name.toString()
};
return JSON.stringify(result);
}
}
return null;
}
Catalog client script :
if (newValue === '') {
g_form.clearValue('assigned_to');
return;
}
var ga = new GlideAjax('<SC_Name>');
ga.addParam('sysparm_name', 'checkSingleUser');
ga.addParam('sysparm_group_id', newValue);
ga.getXMLAnswer(function(answer) {
if (answer) {
var userObj = JSON.parse(answer);
g_form.setValue('assigned_to', userObj.sys_id);
} else {
g_form.clearValue('assigned_to');
}
});
If my response helped mark as helpful and accept the solution.