# How to remove a role of a user in ignition with scripts

**URL:** <https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [December 1, 2020, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091 "2020-12-01T15:58:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![retinder.labana](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@retinder.labana](https://forum.inductiveautomation.com/u/retinder.labana)\
**Post date:** [December 1, 2020, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091/1 "2020-12-01T15:58:56Z")

</div>

I tried deleted role of a user via SQL query  
delete from scada\_user\_rl where user\_id =  
( select id from scada\_users where primaryEmail =:email )

but that did not work. I can add roles to a user using SQL query but cannot delete it.

Is it possible to delete it via scripts? If so, how would you go about doing that?

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [December 1, 2020, 4:39pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091/2 "2020-12-01T16:39:32Z")

</div>

This is entirely untested, but it looks like you can get a User object with:

> system.user.getUser(userSource,username)

Then from looking at this [link](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.12/com/inductiveautomation/ignition/common/user/PyUser.html#setRoles(java.util.Collection)) you should be able to use this on that user object

> removeRole('role')

so something like:

> userToEdit = system.user.getUser(userSource,"username")  
> userToEdit.removeRole("role")

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 1, 2020, 4:50pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091/3 "2020-12-01T16:50:24Z")

</div>

You’d also need to save the user afterwards.

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [December 1, 2020, 5:05pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091/4 "2020-12-01T17:05:37Z")

</div>

Then as Kathy says, save it!

> ` system.user.editUser(userSource, userToEdit)`

---

<div class="post-metadata">

**Author:** ![retinder.labana](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@retinder.labana](https://forum.inductiveautomation.com/u/retinder.labana)\
**Post date:** [December 1, 2020, 5:40pm UTC](https://forum.inductiveautomation.com/t/how-to-remove-a-role-of-a-user-in-ignition-with-scripts/41091/5 "2020-12-01T17:40:53Z")

</div>

This works for any user?

I can call any user and remove roles assigned to them
