- 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
‎06-19-2023 03:17 AM
Hi,
Create a Before insert/update business rule. it will work on form and List as well.
Thanks!!
Ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2023 03:24 AM
Just create a before update BR.
In the condition you can set it to check that assignment group changes.
Then in the script perhaps something like
if(current.assigned_to == previous.assigned_to){
current.assigned_to = '';
}
This would check if the assigned_to is still the same person and set it to empty.
Of course there's a chance that same person is in another group and is selected again, but I think that's pretty rare and shouldn't be an issue. This would also apply on the form update, so it's not just on the list view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 03:41 AM - edited ‎06-20-2023 04:02 AM
Hi @Weird ,
Thanks for your response, I have tried it and its working but I need to take care if same assigned to present in the other group also. Do you have any idea how we can take care of this scenario ?
I am trying like below but its not working.
if (!current.assignment_group.getRefRecord().getMembers().contains(current.assigned_to)) {
if(current.assigned_to == previous.assigned_to){
current.assigned_to = '';
}}
Thanks,
Brij
- 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.