Clone wiki

JIRA Workflow Toolbox / amazing / Assign issue to a user by Project Role

Assign issue to a user by Project Role

Assign an issue to a user in a project role. In case there are more than one user with the project role, you can set a user as default for a project role in a project. You can use this functionality with every post-function in the plugin that allows you to write on any field of type User or Multi User.

There are other implementations available for doing the same, but they usually require a user property for each project and role, and in case you use a big number of projects and project roles, the configuration may require a lot of effort to configure and usually is prone to errors.

Usable Features

You can use any of the following post-functions:

  • Assign to Project Role, with the following 12 assignment modes:
    • default user for project role.
    • default user for project role, except if current assignee is already in project role.
    • last user in project role who has had the issue assigned.
    • last user in project role who has had the issue assigned, or lacking that to default user for project role.
    • previous user in project role who has had the issue assigned. (available since version 2.2.35)
    • previous user in project role who has had the issue assigned, or lacking that to default user for project role. (available since version 2.2.35)
    • random user among those in project role, except if current assignee is already in project role.
    • random user among those in project role different from current assignee.
    • least busy user in project role, i.e., user with fewer non-closed assigned issues (non-closed issues = empty resolution).
    • least busy user in project role, except if current assignee is already in project role.
    • next user in selected group and project role according to round-robin algorithm. (available since version 2.2.33)
    • next user in selected group and project role according to round-robin algorithm, except if current assignee is already in project role. (available since version 2.2.33)

  • Copy a parsed text to a field: useful to assign parent issue by project role, or to set custom fields of types user picker and multi-user picker by project role.
  • Set a field as a function of other fields: to assign issues to different project roles depending on the value of other virtual or custom fields values.
  • Write field on linked issues or subtasks: to assign by project role subtasks, sister subtasks, linked issues or transitively linked issues.
  • Write field on issues returned by JQL Query or Issue List: to assign by project role any issue returned by a JQL query or issue list expression.

How to do it

The most easy and direct way to assign an issue by project role is using post-function Assign to Project Role, but you can also simply copy the name of a project role into virtual field Assignee. This way you can use post-functions "Write field on linked issues or subtasks", "Write field on issues returned by JQL Query or Issue List" and "Set a field as a function of other fields", to assign any issue, or to make conditional assignments.

Actually by copying the name of a project role you can set any field of type User and Multi User besides Assignee.

When you have more than one user playing the same project role in a project, you can set a user as default for a project role within a project.

Setting default user for a project role within a project

There are two ways to set the default user for a project role within a project: by project property and by user property.

  • Project property: adding in project's Description a pair key-value called project property (a string with format {property_name=property_value}) that will ne used to set the default user for a project role:
    • {project_role_name=user_name}
      example: {Developers=albert.einstein}

    • {projectRolexxxxx=user_name}
      example: {projectRole10100=richard.feynman}, where 10100 is the ID of the project role.
  • User property: adding a property to the user you want to be the default for a project role.
    • key = project_role_name
      value = regular_expression, to be matched by the project key or by the project category name.

      example: key=Developers and value=CRM|TRB|JWKT, sets the user with the property as default user for project role Developers in projects with keys CRM, TRB and JWKT.

    • key = projectRolexxxxx, where xxxxx is the ID of the project role.
      value = regular_expression, to be matched by the project key or by the project category name.

      example: key=projectRole10100 and value=JAVA Projects, sets the user with the property as default user for project role with ID 10100 in projects with category JAVA Projects.

      example: key=projectRole10200 and value=[ABCD]...|..CR, sets the user with the property as default user for project role with ID 10100 in projects with project keys of 4 characters with A, B, C OR D as first character, or ending by CR.


Using projectRolexxxxx instead of project_role_name as property name has the advantage that you can rename the project role without having to update the project property.

In case you set project role's default user using both, project properties and user property, then default user set by project properties will be used instead of the one set by user property.

Example:

We want to set user richard.feynman as the default user for project role Developers (being 10100 the project role ID) in a project with key CRM.

Using project property to set default user for a role:

We can add in project description the property {Developers=richard.feynman}, or alternatively we ca use the property {projectProperty10100=richard.feynman}.

./amazing/assign-by-role/assign-by-project-role-1-2.png

Using user property to set default user for a role:

We add a user property to the user we want to be the default user for the project role:

./amazing/assign-by-role/assign-by-project-role-3-4.png

Load Balancing: Assigning to the Least Busy User in a Project Role (since version 2.2.33)

Post-function Assign to Project Role has 2 options for assigning issues to the least loaded user in a project role:

  • least busy user in project role, i.e., user with fewer non-closed assigned issues
  • least busy user in project role, except if current assignee is already in project role.

An issue is considered non-closed if it has unset Resolution.

Since version 2.2.33, it's possible to insert a JQL Query for restricting the issues to be considered when calculating the least loaded user. This way you can assign the issue to the user with fewer non-closed issues in the project, like in the example:

./amazing/assign-by-role/assign-least-busy-exemple.png

There are also 3 parser functions in order to select the least loaded user in a project role. This functions can be used for assigning issues in sub-tasks, linked issues, JQL selected issues or newly created issues using post-function Create issues and subtasks:

FUNCTIONRETURNED VALUE
leastBusyUserInRole(string projectRoleName) : string
Available since version 2.2.8
Returns the name of the active user playing project role with name projectRoleName in current issue's project, and has the lower number of issues with resolution empty assigned; or null if there isn't any user in the project role. Parameter projectRoleName can be a comma separated list of project role names, returning the least busy users among the project roles.
Example: leastBusyUserInRole("Developers") returns the user playing role Developers in current project with the least number of unresolved issues in all the JIRA instance assigned.
leastBusyUserInRole(string projectRoleName, string projectKey) : string
Available since version 2.2.8
Equivalent to the previous function but with extra argument projectKey for selecting the project argument projectRoleName refers to.
Example: leastBusyUserInRole("Developers", "CRM") returns the user playing role Developers in project with key CRM with the least number of unresolved issues in all the JIRA instance assigned.
leastBusyUserInRole(string projectRoleName, string projectKey, string jqlQuery) : string
Available since version 2.2.33
Equivalent to the previous function but with extra argument jqlQuery, used for restricting the issues to be considered to pick the least busy user.
Example: leastBusyUserInRole("Developers", %{00018}, "project = " + %{00018}) returns the user playing role Developers in current project, with the least number of unresolved issues in current project assigned. Note that %{00018} is field code for Project key.



Assigning to Users in Project Role by Round-Robin (since version 2.2.33)

Since version 2.2.33, post-function Assign to Project Role has 2 options for assigning issues by turns using round-robin algorithm:

  • next user in selected group and project role according to round-robin algorithm.
  • next user in selected group and project role according to round-robin algorithm, except if current assignee is already in project role.

Round-Robin Queue

This kind of assignment requires to select a group, which in combination with the selected project role, define a round-robin queue. Each time post-function Assign to Project Role is executed in any workflow with the same configuration (i.e., same group and project role), the issue will be assigned to the next user in the round-robin queue.

The round-robin queue consists of all the users in the selected group an project role at the same time.

Example of Assignment by Round-Robin

Assigning the issue to users in project role Developers and group jira-developers by round-robin:

./amazing/assign-by-role/assign-round-robin-exemple.png
There are also 1 parser function to select users by round-robin. This function can be used for assigning issues in sub-tasks, linked issues, JQL selected issues or newly created issues using post-function Create issues and subtasks:

FUNCTIONRETURNED VALUE
nextUserInGroup(string groupName, string queueName) : string
Available since version 2.2.33
returns the name of the next active user in group with name groupName, for a round-robin queue with name queueName. The string queueName is an arbitrary name. The queue is automatically created the first time a queue is used in a function call. Each time the function is called on the same pair of arguments (group, queue), a different user in the group is returned. The queue can be used in different transitions of the same or different workflows within the same JIRA instance.
Example: nextUserInGroup("jira-developers", "code-review-queue") returns the username of the next user in group jira-developers for round-robin queue code-review-queue. Each time the function is called with the same pair of arguments, a different username is returned.



Other Examples

  • EXAMPLE 1: We use post-function "Assign to Project Role" to assign current issue to default user set for project role "Developers".

    ./amazing/assign-by-role/assign-by-project-role-7-1.png
    ./amazing/assign-by-role/assign-by-project-role-7-2.png

    Once configured transition's post-function tab looks like this:
    ./amazing/assign-by-role/assign-by-project-role-7-3.png


  • EXAMPLE 2: We use post-function "Copy a parsed text to a field" to assign parent issue to project role "Developers".

    ./amazing/assign-by-role/assign-by-project-role-4-1.png

    Once configured transition's post-function tab looks like this:
    ./amazing/assign-by-role/assign-by-project-role-4-2.png


  • EXAMPLE 3: We want to assign higher priority issues to more experienced teams and lower priority issues to less experienced teams.

    We use post-function "Set a field as a function of other fields" to set field "Assignee" with a certain project role depending on issue priority. "Rookie", "Junior", "Senior" and "Manager" are project role names the issue will be assigned to depending on issue priority:

    ./amazing/assign-by-role/assign-by-project-role-6-1.png
    Setting rules are: (Trivial)Rookie (Minor)Junior (Major|Critical)Senior (Blocker)Manager

    Once configured transition's post-function tab looks like this:
    ./amazing/assign-by-role/assign-by-project-role-6-2.png


  • EXAMPLE 4: We use post-function "Write field on linked issues or subtasks" to assign subtasks to project role "Developers" regardless of its type or status.

    ./amazing/assign-by-role/assign-by-project-role-5-1.png
    ./amazing/assign-by-role/assign-by-project-role-5-2.png
    ./amazing/assign-by-role/assign-by-project-role-5-3.png
    ./amazing/assign-by-role/assign-by-project-role-5-4.png
    ./amazing/assign-by-role/assign-by-project-role-5-5.png
    ./amazing/assign-by-role/assign-by-project-role-5-6.png


    Once configured, transition's post-function tab looks like this:

    ./amazing/assign-by-role/assign-by-project-role-5-7.png

Related Usage Examples

Updated