Display the membership tree for a given group and provide users with the ability to add, remove, and move user members from a single interface.
The user and group browsers provide the ability for users to manage group membership from Tempo. In this recipe, you will learn how to configure an interface that enables users to perform the following operations:
Add user members to a group
Remove user members from a group
Move a user members from one group to another
For this recipe, you will need a group membership tree to test with. We used a department structure within a software engineering company, but feel free to use any hierarchy you want.
Once you have created your groups and users, you will be ready to begin constructing the interface and process by following the steps below:
From the Application Designer, create a new interface called EX_addMoveRemoveUsers with the following inputs:
ri!initialGroup (Group) - the group whose direct members display in the first column of the browser, necessary to re-initialize the component after submittal
ri!navigationPath (User or Group array) - the navigation path that the user was seeing when the form was submitted, necessary to re-initialize the component after submittal
ri!usersToAdd (User Array) - the users to add as members to the ri!addToGroup
ri!addToGroup (Group) - the chosen group to add users to
ri!userToRemove (User) - the chosen user for the remove action
ri!removeFromGroup (Group) - the group from which the ri!userToRemove is being removed
ri!userToMove (User) - the chosen user for the move action
ri!moveFromGroup (Group) - the chosen group to move the ri!userToMove from
ri!moveToGroup (Group) - the chosen group to move the ri!userToMove to
ri!btnAction (Text) - determines flow of the process. Can be "ADD", "REMOVE", or "MOVE"
Copy the following text into the expression view of EX_addMoveRemoveUsers
Notable Expression Details
The comments in the expression above point out many difficult concepts in this recipe. Some of the most important to note are listed below:
When managing group membership in process, keep track of the navigation path. This allows you to reinitialize the browser where the user left off, creating the feeling that the user never leaves the form. At the same time, you must be sure that the navigation path does not become invalidated due to altered group membership. In the example above, if a user is removed from a groups membership, it is also removed from the navigation path.
To extract the parent of the selected value from the path, use the following expression:
If using a user & group browser, use the runtimetypeof() combined with 'type!User' and 'type!Group' to determine what type of value is selected.
If using the recipe for a related action, pass the initial group in the related action context and remove the group picker from the interface.
Getting the Interface into a Process Model
To be able move group members, we need to use a process. We will continue this recipe by:
Create a new process model called "Manage Group Members"
Add a new user input task, called "Manage Group Members", connecting it to the start node. Make the connection an activity chain.
Set this as a user input task rather than a start form so that you can loop back to it
On the Forms tab, enter the name of your EX_addMoveRemoveUsers interface in the search box and select it
Click Yes when the process modeler asks, "Do you want to import the interface inputs?". This will create node inputs.
On the Data Tab, for each activity class variable, add a duplicate process variable to save the activity class variable.
For initialGroup, set the corresponding process variable as the input value
For navigationPath, set the corresponding process variable as the input value
Assign the task to the process initiator
At this point, you can connect the input task to the end node to have a functional process. Feel free to do this to test out your interface. None of the buttons will work, but that is coming up next. Before continuing, make sure to undo the testing connection between the input task and the end node.
Next, create a new XOR node below the input task and name it "Do What?" Connect the two with an activity chain.
Next, move the end node to the left of the XOR, and connect the two.
Your process should now look like this:
Now you can start to actually build the nodes that handle the actions.
Create three new sets of nodes, stemming from the gateway. Activity chain all connections going forward.
"Add Group Members" - do not change the name
"Remove Group Members" - change name to "Remove Group Member"
"Add Group Members" connected to a "Remove Group Members" - change the names to "Add Group Member for Move" and "Remove Group Member for Move," respectively
Connect "Add Group Members," "Remove Group Member," and "Remove Group Member for Move" back to "Manage Group Membership," and activity chain the connections
At this point, your process should look something like this:
Next, configure the "Do What?" logic
If pv!btnAction = "ADD" is True, then go to "Add Group Member"
Else If pv!btnAction = "REMOVE" is True, then go to "Remove Group Member"
Else If pv!btnAction = "MOVE" is True, then go to "Add Group Member for Move"
Else if none are true, go to "End Node"
Finally, configure the remaining nodes in the process model and publish as an action.
In "Add Group Member"
Set "Choose New Members" to pv!usersToAdd
Set "Choose Group" to pv!addToGroup
In "Remove Group Member"
Set "Choose Members" to pv!userToRemove
Set "Group" to pv!removeFromGroup
In "Move to Group"
Set "Choose New Members" to pv!userToMove
Set "Choose Group" to pv!moveToGroup
In "Move from Group"
Set "Choose Members" to pv!userToMove
Set "Group" to pv!moveFromGroup
Save & Publish the model
From the Application Designer, go to settings, then Application Actions. Add the process model, "Manage Group Members," as an action called "Manage Group Members."
Publish your application
Test it Out
At this point, you are ready to manage your groups membership. To try it out:
Go to the actions tab, click on your new action, Manage Group Members
Click on a group and click Add Members
In the picker, type in names of users, and click Add Users to submit the form. You should be brought back to the interface, and the users should now appear as members of the group.
Click on one of the new users
Click Remove Member. The user should no longer be a member of the group.
Click on another user
Click Move Member.
Click on another group or type a group name in the picker. Click Move User to confirm. The user should now be moved.