Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How do I compare and update a custom field value be subtask and parent in a script listener?

Deleted user Aug 25, 2017

I'm trying to update a custom field when the field is updated on the subtask so the parent shows the new value.

in the Script Listener console, issue.fields.parent.key doesn't work because 'parent' is not a known class in JSON.

I got that line from the Scriptrunner for JIRA Cloud examples.

 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Neta Elyakim
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.
Jul 18, 2018

It's will work on Listener like that

if(issue.fields.issuetype.subtask == true){    
String parentkey= issue.fields.parent.key  
}

and if you are in script console do this:

 def issueKey = 'COPY-19' // enter you sub task key here

def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
def parentIssue = result.body.fields["parent"]
return parentIssue["key"]
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}
TAGS
AUG Leaders

Atlassian Community Events