Find assigned to is member of particular group

Dileep2
Tera Contributor

Hi All,

 

I have assigned to field referencing to user table. Now I want to check if the Assigned to user is part of  "BCKAM -200&210" group. If Yes I have to clear Assignment group field value.

 

Please suggest any solution.

8 REPLIES 8

Basheer
Mega Sage

Hi @Dileep2 ,

Follow the below script

var user = current.assigned_to;
var group = "abc";//this should be sysid of the group BCKAM
//You can directly use .isMemberOf("group name") to check whether the user is part of the group or not.

var groupMember = new GlideRecord("sys_user_grmember");
groupMember.addQuery("group",group);
groupMember.addQuery("user",user);
groupMember.query();
if(groupMember.next()){
current.assignment_group = " " ;//Emptying the assignment group
current.update();
}

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Mohith Devatte
Tera Sage
Tera Sage

Hello @Dileep2 ,

You can do it like this if you doing this in before BR 

if(current.assigned_to.isMemberOf('your_group_name')==true)

{

current.assignment_group ="";

}

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

 

 

Anubhav24
Mega Sage
Mega Sage

Hi Dileep , 

You need to first decide on what event you need to have a check for this. On change of assigned to field or on submission of the record.

If you need to do client side validation in that case you will need to have script include call from your onchange client script.

Hi Anubhav,

 

Thanks for the solution, I followed the same but I am not sure what to write in the code. I want OnChange of Assigned to field,

Please post me code

 

Thank you