The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Remove Roles From a Group

Surbhi16
Tera Contributor

HI, 

How can we remove role from a group using script?

Is there any way we can delete any role from a group based on user input?

Regards,

Surbhi

17 REPLIES 17

Yeah, I am trying this script but its not working, actually I am using this script in script action of virtual agent but its not working out for me:

find_real_file.png

Hi,

Can you please check what are the values in input Variables?

They must contain group sys_id and Role sys_id.

If your variables contain name of group and name of role then use  below script:

var role = new GlideRecord('sys_group_has_role');
role.addQuery('group.name', vaInputs.grou_name);
role.addQuery('role.name', vaInputs.role_to_be_removed);
role.query();
while(role.next())
{


role.deleteRecord();
}

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi Anil,

These are my variables, Your above script are not working out for me

find_real_file.png

 

find_real_file.png

Regards,

Surbhi

Hi,

Have you tested your topic ? see what are the values of these variables in logs.

Can you please share your complete topic flow?

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Also can you please share what are the tables selected in your Input Variables for group and role?

var role = new GlideRecord('sys_group_has_role');
role.addQuery('group', vaInputs.group_name);
role.addQuery('role', vaInputs.group_role_to_be_removed);
role.query();
while(role.next())
{
role.deleteRecord();
}

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande