Filter the users from a database
Required apps
Level: BASIC
The following problems were actually the reason we created User Group Picker PRO. These are basic problems and start on the premise of a collection of users (added by other means) in the Jira database. Both external systems and Jira help maintaining this collection of users which are actually augmenting the Jira user with various flags.
In fact, it is just an accident (not so - actually a common case) that we're using the database for our collection of users. The truth is that you can use anything as a user source: LDAP (via ldapUserRecord), files, and so on.
Problem1
Get all users having supervisor flag on.
Solution
Use sql routine in the SIL code for the custom field of type SIL User Group Picker.
//Select all users having supervisor flag on. return sql("TestDB", "select u.user_name from users u, userpermissions up where u.user_id=up.user_id and up.supervisor=true;");
The code above returns the list of users having supervisor flag set to true.
Problem2
Get all employees from a certain branch.
Solution
Use sql routine in the SIL™ code for the custom field of type SIL™ User Group Picker like in the following code example:
//Select all employees from a certain branch. return sql("TestDB", "select user_name from employees where branch_number=1;");
The code above returns the list of employees having supervisor flag set to true.
The returned results should have the corresponding users created in Jira. The username of the Jira users should match the values from the user_name column.
See also
- Copy field value from parent
- Default values of (system) fields on create screen
- Make a custom field required based on another custom field
- Reset a field
- Restrict a select list to not show certain values
- Rolling summation or subtraction between parent and child fields
- Selecting users member of the reunion of 2 sets intersected with a third one
- Use Live Fields to initialise field values for a transition screen
- Using Database custom fields queries: IN clauses