- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 11:55 AM
Hi,
I need to populate assigned to based on assignment group. I have written this code and it is not working.
Please correct my code to make it work.
Regards,
Nivedita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 03:44 AM
You can write below code in script include, its working on my PDI.
Script include code :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:31 PM
I dug up this one from a while back from my scripts. Can you try that? I think you're missing the 'join'. But on a different not: why set assignment group/assigned to from a catalog item? Isn't it better to just have the user create a ticket and use assignment rules to route that ticket to the correct group/user? You are letting users assign tickets. That's a process I wouldn't be happy with as an agent that needs to pick things up.
(function() {
var groupId = current.variables.assignment_group; // Assuming 'assignment_group' is the variable name for the assignment group
if (groupId) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', groupId);
gr.query();
if (gr.hasNext()) {
// If the group has members, return only members of this group
return 'sys_idIN' + getGroupMemberIDs(groupId);
}
}
// If the group has no members or no group is selected, return all active users
return 'active=true';
})();
function getGroupMemberIDs(groupId) {
var memberIDs = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', groupId);
gr.query();
while (gr.next()) {
memberIDs.push(gr.user.toString());
}
return memberIDs.join(',');
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 04:45 AM
@niveditakumari, any luck with the script?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 11:40 PM
Hi @niveditakumari ,
If you want to show only users who are member of Assignment group in Assigned to Field then you can go to dictionary of "Assigned to" field and under Dependent Field Section you can give Assignment group backend name as shown below ,
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 03:33 AM
Hello Nivedita ,
could you please try below script its's working on my instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 12:15 PM
HI @Rohini S Sane,
Thank you so much for your help. It is working now.
I'm trying this code to populate assignment group based on assigned to field I have written code.
Can you please correct that to make it work.
Regards,
Nivedita