Set Assignee to match Parent's Custom Field Value

I'm using Jira and the Script Runner plugin to Create a sub-task on transition. That's all working well. However, I cannot seem to set the 'Assignee' of the Subtask to match the value of the 'Project Manager' listed on the parent (which is a custom field). Below is what I am using, But it does not work. What is the correct way to write this?:

issue.assignee = transientVars["originalissueobject"].cfValues['Project Manager']


I've Seen similar posts like this and this but nothing that shows how to Set the Assignee of a Sub-task based on the the Custom Field Value of the Parent Issue.  Thanks for you Help!

2 answers

1 accepted

0 votes
Accepted answer

@Alejo Villarrubia [Adaptavist], you were definitely on the right track. I wasn't able to get your script to work, but I found a very similar script here that worked perfectly! Thank you so much for your help!

import com.atlassian.jira.user.ApplicationUsers
cfParent = customFieldManager.getCustomFieldObjectByName('Project Manager')
parentMyFieldValue = transientVars["issue"].getCustomFieldValue(cfParent)

Hi @Michael Romrell,

Can you try this out?

import com.atlassian.jira.component.ComponentAccessor

def projectManagerCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Manager")
def projectManager = issue.getCustomFieldValue(projectManagerCF)

if (projectManager) {

Hope it helps

Thank you for your reply!! To Do that, I Assume that I would add this as a post function on the "Create" Transition of my sub task (Via Script Runner's). The only issue is that I don't have direct access to upload my own script files (That requires lots of bureaucracy). Is there another way I can try out your script?

No problem. There is no need to upload the script actually. You can simply replace the code that your instance already has in the "Additional issue actions" with the one I shared.

Unfortunately, It isn't working (It won't create a subtask with that script in place). To be verify that I'm adding it to the right place. The script is going in the "Additional Issue Actions" field of Script Runner's "Create Sub-Task" Post Function which is tied to the parent transition. Is that correct? ---- I should also mention that the plugin, MISC JIRA Worflow's "Copy Value From Other Field" Post function performs the exact task that I need, however, I cannot get that, or any, post function to work on the subtask's "Create" Transition. but on any other subtask transition, that particular post function will actually assign the Subtask based on the custom field value of the parent.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,073 views 4 9
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