User Role Replace

I have a user role e.g. ‘CurrentRole’ with a range of permissions on an app.  I want to create a new user role e.g. ‘NewRole’ with only one user and with all the permissions that CurrentRole has and then remove CurrentRole so that all the users of CurrentRole has all those permissions taken away, leaving one user with the original permissions and all other users automatically restricted.  Is there an easy / easier way to do this without causing loads of errors?  
5 answers

If I understand correctly you want to remove the user role 'CurrentRole’ from all users except for one? Maybe it is easier to create a microflow that retrieves all users that have that UserRole and remove this role? 

You can retrieve System.UserRole with id =  ‘[%CurrentRole%]’ and all associated users. Then you can iterate over this list and remove the role 'CurrentRole’  from the association for every user (except for the one you want to keep). I hope this helps


I don't think you need Administration.Account as input for your first microflow.

1)You can first do a retrieve on database of UserRole with [id = '[%UserRole_CurrentRole%]'] (select range option first) → This gives you the UserRole to remove

2)Then you can retrieve all System.User over association from the UserRole you just retrieved. → This gives you all users that have that role

3)Then you can loop over the userList and change the association userRoles, where you remove UserRole (that you retrieved in step 1)

4)Commit the userList



In the first step you retrieve a list of userRole → select for the option range ‘First’:

In Step 2 you do : Retrieve list of $currentUser/UserRoles by association

With this retrieve you retrieve all userroles of your current user.

However, you want to retrieve all users that have the role ContactCentreAgentList. So you should retrieve list of $ContactCentreAgentList_UserRoles by association. Let's call this UserList


iterate over UserList (IteratorUser) and remove the UserRole


Commit the userList:


OK so a button that calls a microflow

Microflow has an Administration.Account (created) input

I then do a retrieve by association on user role CurrentRole

Then do I use a loop with a Change List > Clear or Remove option? Or use the Delete Object option?

Or is it better to do a retrieve from database with XPath?

[System.UserRoles/System.UserRole/Name = 'ContactCentreAgent'] for example...



Doesn't seem to be working for me...

Retrieve system.UserRole with XPath:

[id = '[%UserRole_ContactCentreAgent%]']

Outputname = 'ContactCentreAgentList'


Retrieve list of $currentUser/UserRoles by association

Outputname = 'UserRoleList'

(not sure what you mean by 'retrieve all System.User over association from the UserRole you just retrieved')


Iterate through UserRoleList (IteratorUserRole)

Change list entity:
Variable name = UserRoleList
Value = $IteratorUserRole
Type = Remove


Commit UserRoleList
Without events
Refresh in client

Exit loop and finish microflow