This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Objective

How to view all the K2 roles that a user is a member of, by specifying the username.

Before You Begin

A Filter will need to be added to the User Roles SmartObject method called Find Role or List Roles. Therefore, you need to note that when configuring the filter for the User Roles SmartObject method, the execution might be a little slow since the filter is filtering on a value which is not an input paramater for the User Roles SmartObject method.

How-to Steps

  1. Create a new List View and bind the data source to the SmartObject called User Role. The SmartObject can be located in System\Management\Users\SmartObjects\User Role.
  2. Select the Find Roles or List Roles method as the list method and continue to the layout tab.
  3. From the Layout, select the Create Labels and Control option and choose "Name" and "User Role Items (User Role Items[])" as the columns to be listed in the list view.

4. Add a text box to the list view as well as a button.

5. Edit the "When form executes initialize" rule and remove the "then execute the [Find Roles or List Roles] method" rule.

6. Add a rule to the button: when button is clicked, then execute the [Find Roles or List Roles] method and click the configure option of this rule.

7. In the configure section navigate to the Filter tab and add the following filter:

Field = UserRoleItems (UserRoleItems[])

Operator = Contains

Value = Text Box (this would be the text box that you have added to the list view.)





8. Finish up the rule creation and save and finish the list view.

9. Run the List View
10. In the Text box you would then type the username for the user that you need to locate the roles for and thereafter press the button.

This will do a check in the UserRoleItems (UserRoleItems[]) column for the User Roles SmartObject and return all the roles that contains the specified username in the string contained for that column, and then display all the roles that the specified user is a member of.

Please note that this has been tested in K2 4.7.