Reference qualifiers not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 03:57 AM
Hlo folks,
When I click on 'assigned to' field in Incident. It should accept only users who are part of 'assignement group' selected. But when i click on 'assigned to' field it is showing the recent selections, when i click them it should show it as invalid if selectd user is not part of assignment group selected but it is not happening it is accepting.
Can anyone help on this.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 04:04 AM
Assigned to is depend on Assignment group and due to this issue is there
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 04:46 AM
Hi @Dr Atul G- LNG,
my issue is it is accepting the users are not part of the assignment group also.
Thankyou for response!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 05:40 AM
Agree , this is what the OOTB system provides. I just tested and it is working. In this case you need to make Assignment group mandatory. OOTB it is not mandatory so it is moving forward.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 04:20 AM
for your scenario you may need to use script include to get the group and call in your client script:
Create a Script Include
Name: ValidateUserInGroup
Client Callable: True
var ValidateUserInGroup = Class.create();
ValidateUserInGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateUserInGroup: function() {
var userId = this.getParameter('sys_id');
var groupId = this.getParameter('group_id');
var userGroupGR = new GlideRecord('sys_user_grmember');
userGroupGR.addQuery('user', userId);
userGroupGR.addQuery('group', groupId);
userGroupGR.query();
return userGroupGR.hasNext();
}
});
Client Script for Assignment Group Field
Type: OnChange
Table: Incident
Field: Assignment Group
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Store the new assignment group value
g_form.setValue('assignment_group', newValue);
// Validate if the current 'Assigned to' user is valid
validateAssignedTo();
}
function validateAssignedTo() {
var assignedTo = g_form.getValue('assigned_to');
var assignmentGroup = g_form.getValue('assignment_group');
if (assignedTo && assignmentGroup) {
var ga = new GlideAjax('ValidateUserInGroup');
ga.addParam('sys_id', assignedTo);
ga.addParam('group_id', assignmentGroup);
ga.getXMLAnswer(function(response) {
if (response === 'false') {
g_form.showFieldMsg('assigned_to', 'The selected user is not part of the selected assignment group.', 'error');
g_form.setValue('assigned_to', '');
}
});
}
}
Client Script for Assigned to Field
Type: OnChange
Table: Incident
Field: Assigned To
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
validateAssignedTo();
}
function validateAssignedTo() {
var assignedTo = g_form.getValue('assigned_to');
var assignmentGroup = g_form.getValue('assignment_group');
if (assignedTo && assignmentGroup) {
var ga = new GlideAjax('ValidateUserInGroup');
ga.addParam('sys_id', assignedTo);
ga.addParam('group_id', assignmentGroup);
ga.getXMLAnswer(function(response) {
if (response === 'false') {
g_form.showFieldMsg('assigned_to', 'The selected user is not part of the selected assignment group.', 'error');
g_form.setValue('assigned_to', '');
}
});
}
}
…………………………………………..
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.