Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

Assigning an issue preserving the user load.

Solution

1. Adding a SIL Post Function

...

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Assign+an+issue+while+maintaining+the+user+load+-+15482938
widthauto

Problem

You want to assign new issues to the user with the least number of tasks to balance the workload across the team.

Solution

Note

This recipe assumes that you already have a project and a workflow associated with it in your Jira installation. If

you don't, please refer to Jira documentation on

not, go to the Jira documentation to find out how to do

that.

Now create draft for the workflow and go to 'Create' transition.

Let's add a new post function. Under the "Post-functions" tab, click "Add" and choose "(k) SIL™ Post-function".

Image Removed InfoInfo

this.

Add a SIL post function

  1. Create a draft workflow.

  2. Go to the Create transition.

  3. On the Post Functions tab, select the Add checkbox.

  4. Select (k) SIL Post-function and click Add.

Image Added

For more information on configuring workflows visit Atlassian

2. Writing

, go to the Atlassian documentation.

Write the code

After you have you’ve added the post function, you are now ready to write the actual code. Immediately after the addition of the post function, you will be presented with our friendly user interface . Now give your program an appropriate name. This will be used as a base for the user interface is displayed.

Enter a name for your program. This is used in the name of the file where the program will be is saved. See Writing Conditions Validators and Post Functions for more examples.For assigning the issue preserving For more examples, go to our documentation on writing condition validators and post functions.

To assign an issue while also maintaining the user load, you should write enter the following code:.

Code Block
string[] prjMembers = projectMembers(project);
string minUser;
number minIssues = -1;
number issuesNumber = -1;
string query = "project = " + project + " AND status in ('Open', 'In Progress', 'Reopened') AND assignee = ";
string jql;
 
for (string user in prjMembers) {
  jql = query + user;
  issuesNumber = arraySize(selectIssues(jql));
  if ((minIssues == -1) || (issuesNumber < minIssues)) {
    minIssues = issuesNumber;
    minUser = user;
  }
}
 
assignee = minUser;

That's it! Click the "Add" button and you're ready to test your program.

Image RemovedImage Added
Note
Note

It is recommended that you move

all

the SIL™

Post Functions

post functions after all other post functions.

You can do that by repeatedly clicking "

To do this, click Move Down

" until it is at the very

until the SIL™ post functions reach the bottom of the post functions list.

3. Testing

Test the code

Next, activate Publish your draft workflow by publishing to activate it.

To test the post function, create a new issue. Fill Complete the required fields and click "Create" button. The issue will be is assigned to the user with the least smallest number of tasks.

4. Assigning issue randomly to project users example

Recently we encountered one case where we needed the issue to be assigned randomly

Example

This is an example of how you can randomly assign an issue to project users.

For assigning To assign the issue randomly, you should enter the following code and make sure to use the random function and write the following code:.

Code Block
string[] prjMembers = projectMembers(project);
number n = arraySize(prjMembers);
 
if (n > 0) {
 assignee = arrayGetElement(prjMembers, random(n));
} else {
 assignee = projectPM(project);
}

Table of Contents

Table of Contents