🚀 JWT 3.0 is out 🚀 

The app was completely overhauled, and so was the documentation: Jira Workflow Toolbox (Server/Data Center) Home

The page you are viewing is still valid for all app versions prior to 3.0.

This function has been renamed with the JWT 3.0 release. 

Find the new documentation at:

Assign to project role

On this page


Purpose

Assigns 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 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 sub-tasks: to assign by project role sub-tasks, sibling sub-tasks, linked issues or transitively linked issues.
  • Update issue fields: to assign by project role any issue returned by a JQL query or issue list expression.

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 sub-tasksUpdate issue fields 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.



Example 1: 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 Properties: adding in project's Description a pair key-value called Project Properties (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.


(info) Independent from this property the user must be in the project role of the selected project, otherwise the function assign to project role will not work.


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.

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}.

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:


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.

Example 2: Load balancing: Assign to the least busy user in a project role

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:


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 sub-tasks:


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.

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 3: Assign to users in project role by round-robin

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


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 sub-tasks


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.

Example 4: Use post-function assign to project role to assign current issue to default user set for project role "Developers"



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



Other examples

Example 5: Use post-function Copy parsed text to a field to assign parent issue to project role "Developers"


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




Example 6: 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:


Setting rules are:

(Trivial)Rookie
(Minor)Junior
(Major|Critical)Senior
(Blocker)Manager


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




Example 7: Use post-function Write field on linked issues or sub-tasks to assign sub-tasks to project role "Developers" regardless of its type or status







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