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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Set assignee based on custom field user picker value using script runner

Hello All,

How to Set assignee based on User Picker custom field value on workflow transition.

For example: 

  • If S1 Admin(user Picker field) is null, change the assignee to automatic assignee automatically
  • If S1 Admin is not null, change the assignee to S1 Admin

Thanks in advance,

Bunty

1 answer

1 accepted

0 votes
Answer accepted

Hi @Bunty 

 

Try this:

import com.atlassian.jira.component.ComponentAccessor

def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField)

if(cFieldValue.name == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}


Regards,

Seba

Hi Seba,

Thanks for the reply.

Script is not working it is showing below error:

L10.PNG

I also got this error but it works. Did you run it?

If it not working please change it a little bit

import com.atlassian.jira.component.ComponentAccessor

def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField).name

if(cFieldValue == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}
Like Bunty likes this

Hi Seba,

Thanks a lot. It worked.

import com.atlassian.jira.component.ComponentAccessor

def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField)

if(cFieldValue == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,407 views 22 32
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you