Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to set "Assignee" field as Reporter or current user in "Create issue" screen

Prabu N August 16, 2018

When create issue screen populated, Assignee contains "Automatic". Instead it should be populate the current user or the reporter (both are same).

 

I am using script runner.

I tried with behaviours; could not get thru.

Anyone can help?

4 answers

1 accepted

2 votes
Answer accepted
Alexey Matveev
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.
August 16, 2018

Hello,

Try to use a code like this:

 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.atlassian.jira.issue.IssueFieldConstants.*
import groovy.transform.BaseScript

def assignee = getFieldById(ASSIGNEE)
def reporter = getFieldById(REPORTER) assignee.setFormValue(reporter.getValue())
Prabu N August 16, 2018

Thanks Alexey! It works like a charm.

 

I written only last 3 lines. and did not have a clue, which object is available in which package (to import)..

Any idea, where i can start learning on these? any knowledge base links.

Alexey Matveev
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.
August 16, 2018

You can find more info here:

https://scriptrunner.adaptavist.com/5.4.12/jira/behaviours-overview.html

If you have any questions, just ask :)

0 votes
Alex Kulichkov
Contributor
July 27, 2021

Hello, Can anyone suggest more recent code version, Scriptrunner throws errors when i try to use code versions above

0 votes
Joe Redmond October 13, 2020

 

I am running this as a post-function via ScriptRunner but it is not setting the assignee for some reason:

if(issue.assignee == null){
     issue.setAssignee(issue.reporter)
     log.info("post assignee " + issue.assignee)
}

 

My log output comes back with 'post assignee THE RIGHT VALUE', but it is not reflected in Jira when I open the issue. 

This seems so simple but not working, any help would be greatly appreciated.

0 votes
Prabu N August 22, 2018

Currently am using below script:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.atlassian.jira.issue.IssueFieldConstants.*
import groovy.transform.BaseScript

def assignee = getFieldById(ASSIGNEE)
def reporter = getFieldById(REPORTER)

if( assignee.getValue() == "-1" || assignee.getValue() == "")
{
assignee.setFormValue(reporter.getValue())
}

 

But it does not work for sub-sequent launches. if i cancel the "create issue" screen and re-launch it then assignee shows as "automatic" only.

It works only if i complete the issue creation successfully.

Any idea, how to enforce this to work every time.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events