Assign to should be empty when assignment group change from list view.

Brijmohan
Tera Contributor

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

 

1 ACCEPTED SOLUTION

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.

View solution in original post

8 REPLIES 8

Ramkumar Thanga
Mega Sage

 

Hi,

Create a Before insert/update business rule. it will work on form and List as well.

 

Thanks!!

Ram

Weird
Mega Sage

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.

Brijmohan
Tera Contributor

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

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.