Access to parent issue fields in groovy listener

Hi

I am testing Groovy listener "Create subtask". My idea is to create subtask and update some fields of this created subtask based from parentissue.

I assume I can add some code in additional issue actions, e.g.

/*subtask summary*/
issue.summary = 'Notestēt risinājumu';
/*find parentissue*/
def parentIssue = issue.getParentObject();

/*find tester in parentissue*/
parentTester=parentIssue.getCustomFieldValue("Tester");

/*find fix version in parent issue*/
parentFixversions=parentIssue.getFixVersions();

issue.assignee = parentTester;
issue.fixversions = parentFixversions;

However when I added this code, subtask was not created. What is wrong?

I detect that I can copy customfield value from createdsubtask to this subtask assignee

This code works:

def cf = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Tester" }
def cfValue = issue.getCustomFieldValue(cf)
issue.setAssignee(cfValue);

However I need fields from parentIssue and I am not able to get it now.

Is it possible to add these actions in listener?

Thank you in advance,

Fyodor

1 answer

1 accepted

How are you adding that first bit of code to the listener? Also when you try and run it, does Jira throw any errors on the screen or logs?

For the second bit of code...Have you tried getting the parent issue with this: issue.getParentObject()? Then you could get the parent field values like you do in the first bit of code.

Hello

Thank you for reply, however my question became out of date so I don't need any help in this problem. Thanks

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,815 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot