The issue creator as default assignee - how to?

Rumceisz April 18, 2013

Hi All,

is it possible in JIRA that the creator of an issue would be the default assignee? THere is a project where most of the users raise issues for themselves. When they raise the issue and set the assignee it will automatically changed to the default assignee.

How can we do that?

Thanks, Rumi

5 answers

1 accepted

2 votes
Answer accepted
Chaithra N
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2013

Hi,

In the workflow, add the postfunction "Assign to Reporter" at create tranistion (Assuming the creator is always same as reporter)

Regards,

Chaithra

2 votes
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2013

You can use the Script Runner plugin and the following simple scripted postfunction

Condition:

!issue.assignee

Script:

issue.assignee = currentUser

as part of the create transition. If the user doesn't change the assignee, the issue is assigned to the current user. If it's changed, the assignee choosen by the user is the assignee.

Henning

1 vote
Thomas Hecker January 18, 2016

Hey Henning,

i'd like to implement your suggestion but I am pretty new to script runner. Can you give me a more step by step help to implement this?

Thanks

Thomas

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2016
  1. Install Script Runner for JIRA
  2. Edit your workflow (in text form).
  3. Click on the step name of the first status, usually "Open".
  4. Click on "Create Issue" incoming transition.
  5. Click on "Post Functions" tab.
  6. Click on "Add post function" link.
  7. Select "Script Post-Function" radio button, click on "Add" button
  8. Click on "Custom script post-function" link.
  9. Enter inline script

    if (!issue?.assignee) {
    	issue.assignee = currentUser
    }
  10. Click on "Add"

  11. Publish workflow.

 

Thomas Hecker March 18, 2016

Hi Henning,

thanks a lot for comming back to me. I tried it but i cannot find an option for entering an inlin script. I can preselect some options or define a path to a script. How do I enter an inline script?

Thanks

Thomas

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2016

Hi Thomas,

in my version there is a (dark blue) inline script field. Did you follow the instructions step by step?

Henning

Thomas Hecker March 20, 2016

Hi Henning,

I did it step by step, but i do not see a dark blue inline script field.

I run JIRA version 6.0.8

Script Runner 2.1.15

Is there maybe some additional configuration within script runner nessecairy?

Thanks

Thomas

Capture.PNG

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2016

Hi Thomas,

in your Script Runner version you have to create a script file on your server (e.g. AssignToMeIfUnassigned.groovy) and enter the path to this file (incl. file name) within the field "Script file path". The content of the script file is the same as the inline script above.

Thanks, 

Henning

0 votes
Ekaterina Nikolich April 11, 2018

Hi All!

I also need to do reporter = assignee. 

I did this step by step and the task was created unassigned. 

Should I change smth in it?

if (!issue?.assignee) {
 issue.assignee = currentUser
}

 

  1. Install Script Runner for JIRA
  2. Edit your workflow (in text form).
  3. Click on the step name of the first status, usually "Open".
  4. Click on "Create Issue" incoming transition.
  5. Click on "Post Functions" tab.
  6. Click on "Add post function" link.
  7. Select "Script Post-Function" radio button, click on "Add" button
  8. Click on "Custom script post-function" link.
  9. Enter inline script

    if (!issue?.assignee) {
     issue.assignee = currentUser
    }
  10. Click on "Add"

  11. Publish workflow.

 

What did I do wrong?

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

Hi,

try

if (!issue?.assignee || issue?.assignee == "-1") {
issue.assignee = currentUser
}

as inline script.

Henning

Ekaterina Nikolich April 12, 2018

No, it doesnt work also and I have a log on it

 

Time (on server): Thu Apr 12 2018 11:27:11 GMT+0300 (Russia TZ 2 Standard Time)

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.

2018-04-12 11:27:11,117 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-04-12 11:27:11,117 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingPropertyException: No such property: currentUser for class: Script1591
 at Script1591.run(Script1591.groovy:2)
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

Ah, ok, than this:

import com.atlassian.jira.component.ComponentAccessor

if (!issue?.assignee || issue?.assignee == "-1") {
issue.assignee = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
}

Henning

Like foryouandyourcustomers likes this
Ekaterina Nikolich April 12, 2018

Henning, thank you , but it also doesnt work.

During pasting the script there were errors. and log on it

2018-04-12 11:51:20,022 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-04-12 11:51:20,022 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingPropertyException: No such property: ComponentAccessor for class: Script1606
 at Script1606.run(Script1606.groovy:2)
Ekaterina Nikolich April 12, 2018

script.jpg

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

I think you forgot the first line, the import in the script (import com.atlassian.jira.component.ComponentAccessor).

Ekaterina Nikolich April 12, 2018

Yes, you are right, sorry,

but it doesnt assigne task to me ((

screen.jpg

Ekaterina Nikolich April 12, 2018

And log

2018-04-12 12:43:13,617 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-04-12 12:43:13,617 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingPropertyException: No such property: ComponentAccessor for class: Script1606
 at Script1606.run(Script1606.groovy:2)
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

Mmmh. Did you publish the workflow after the last change? The row number for the error is still 2 ("...at Script1606.run(Script1606.groovy:2)", so the import row seems still to be missing,

Ekaterina Nikolich April 12, 2018

Yes, I published it after changing. Thank you very much for your help and your time and your responsiveness!!! 

And could you please help me to change script with some conditions 

Assign issue to reporter by default, 

but if other assignee is selected during the creation of the task, assign issue to the  other assignee..

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

Does it work now?

For the condition please try

import com.atlassian.jira.component.ComponentAccessor
import webwork.action.ServletActionContext

def assignee = issue?.assignee

def request = ServletActionContext.getRequest()
if (request) {
def values = request.getParameterValues('assignee')
if (values && values.size() == 1) {
assignee = values[0]
}
}

if (!assignee || assignee == "-1") {
issue.assignee = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
}
Ekaterina Nikolich April 12, 2018

No...

it assigned to the project lead of this project.

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

I added some logging, please try this and report back the log entries.

import com.atlassian.jira.component.ComponentAccessor
import webwork.action.ServletActionContext

def assignee = issue?.assignee
log.error "assignee: $assignee"
def request = ServletActionContext.getRequest()
log.error "request: $request"
if (request) {
def values = request.getParameterValues('assignee')
log.error "values: $values"
if (values && values.size() == 1) {
assignee = values[0]
log.error "assignee: $assignee"
}
}

if (!assignee || assignee == "-1") {
issue.assignee = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()
log.error "assignee changed to ${ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()}"
}
Jimmy Van (GLiNTECH)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2019

Just wanted to say this still works in 2019 on 7.13, will test on Jira 8 soon. Thanks @Henning Tietgens !

0 votes
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 18, 2013

They can also just click the assign to me link underneath the Assignee dropdown box. Then both your workflows are possible.

Suggest an answer

Log in or Sign up to answer