- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 02:26 AM
Hi,
I want to achieve one requirement. If assignment group change , assigned to field should be empty in list view. We can achieve it on form view via on change client script but how we can do it in list view.
Thanks & regards,
Brij
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 11:43 PM
You could just query the group membets table.
var onGroup = false;
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery("group="+current.assignment_group+"^user="+previous.assigned_to);
grMember.query();
if(grMember.next()){
onGroup = true;
}
if(current.assigned_to == previous.assigned_to && !onGroup)){
current.assigned_to = ''; //User is not in the new group
}
Basically this checks if the previous assined to is a member of the current group. If they are, then they can stay as the assigned to. If they're not, then the assigned to is set as empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 10:20 AM
Hey Weird,
LOL, can this be achieved using the onChange Client Script? I've used your logic to create a BR, and it is working as expected. Can it be done via onChange?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 03:30 AM
Hi there,
You can create before BR (apply on both form and list view) with insert/update with conditions are:
'Assigned to' is not empty AND 'Assignment group' changes AND 'Assignment group' is not empty
=> In the Actions tab, set 'Assigned to' to empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 03:38 AM
@Community Alums , thanks for your response, I have tried it but it clearing value of assigned to when we are changing assigned to and assignment group both at the same time.
Thanks,
Brij
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 08:34 PM
Hi @Brijmohan ,
Below BR will satisfy in case of changing Assignment Group: clearing Assigned to when they are not a group member and keep them if they are:
Insert/Update - Before - Conditions: Assigned to is not empty AND Assignment group changes AND Assignment group is not empty
Script:
var assigned_to = current.assigned_to;
var assignment_group = current.assignment_group;
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.sys_id', assignment_group);
grp.addQuery('user', assigned_to);
grp.query();
if (!grp.hasNext()) {
current.assigned_to = '';
}
Firstly find if there is any OOTB "Abort changes on group" on your table so you can modify on that, if not create new as above.