The issue creator as default assignee - how to?

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

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 Community Champion Apr 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

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 Community Champion Mar 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.

 

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 Community Champion Mar 18, 2016

Hi Thomas,

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

Henning

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 Community Champion Mar 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

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

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 Community Champion Apr 12, 2018

Hi,

try

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

as inline script.

Henning

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 Community Champion Apr 12, 2018

Ah, ok, than this:

import com.atlassian.jira.component.ComponentAccessor

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

Henning

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)
Henning Tietgens Community Champion Apr 12, 2018

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

Yes, you are right, sorry,

but it doesnt assigne task to me ((

screen.jpg

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 Community Champion Apr 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,

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 Community Champion Apr 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()
}

No...

it assigned to the project lead of this project.

Henning Tietgens Community Champion Apr 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()}"
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

82 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you