Filter the users from a database

Required apps


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