# Help with UIResponse for system.user.editUser()

**URL:** <https://forum.inductiveautomation.com/t/help-with-uiresponse-for-system-user-edituser/117993>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [November 30, 2026, 12:41pm UTC](https://forum.inductiveautomation.com/t/help-with-uiresponse-for-system-user-edituser/117993 "2026-11-30T12:41:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 30, 2026, 12:41pm UTC](https://forum.inductiveautomation.com/t/help-with-uiresponse-for-system-user-edituser/117993/1 "2026-11-30T12:41:33Z")

</div>

Hi!

I'm making a script where you edit the roles of a user.

```python
# Not real code, simplified
def edit_roles(user, role_list):
  user_obj = system.user.getUser("", user)
  user_obj.addRoles(role_list)
  system.user.editUser("", user)
  return

```

I would like to generate a return message that contains a list of the result of each role execution. I'm not sure on how to do it. 😕

Something like:

```python
[
  {
    "role": "Role1",
    "result": "OK",
    "message": "Role1 was added correctly."
  },
  {
    "role": "Role2",
    "result": "NOK",
    "message": "Group 'Role2' not found"
  },
  ...
]

```

I know about the UIResponse, but not sure on how to link it with each role added. The functions `getInfos()`, `getWarns()` and `getErrors()` are not well documented, so I don't know in what case what is returned and how to set it up.

Any idea on how to do this?  
Changing things in the code it's okey for me.

Thx in advance!

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 30, 2026, 1:39pm UTC](https://forum.inductiveautomation.com/t/help-with-uiresponse-for-system-user-edituser/117993/2 "2026-11-30T13:39:02Z")

</div>

I asked Inductive. This is more complicated than I thought. I belive I need an inside view of how the code works.  
I will post here the response.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [November 30, 2026, 1:52pm UTC](https://forum.inductiveautomation.com/t/help-with-uiresponse-for-system-user-edituser/117993/3 "2026-11-30T13:52:12Z")

</div>

```python
roles = system.user.getRoles(userSource)

```

If that works on your startup session event

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43e6bf8a1034644443bf1995e8ca657063c4310f.png)

you may try with:

```python
userSource = "default"
userName = self.session.props.auth.user.userName

user = system.user.getUser(userSource, userName)
roles = list(user.getRoles())

if "Tecnico" in roles:
# User has this role
pass

```

assign role

```python
userSource = "default"
userName = self.session.props.auth.user.userName

user = system.user.getUser(userSource, userName)
roles = list(user.getRoles())

if "Tecnico" not in roles:
roles.append("Tecnico")
user.setRoles(roles)
system.user.editUser(userSource, user)

```

remove role

```python
userSource = "default"
userName = self.session.props.auth.user.userName

user = system.user.getUser(userSource, userName)
roles = list(user.getRoles())

if "Tecnico" in roles:
roles.remove("Tecnico")
user.setRoles(roles)
system.user.editUser(userSource, user)

```
