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

Update all Subtask Components Field Automatically if anyone Update the Parent Issue Component field

When I am Using Below Code and Update My Parent issue Components field my Subtask issue Components are not Updating.

----------------------------------------------------------------------------------------------------

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
// current issue
def issue = event.issue as MutableIssue
if (issue.getIssueType().getName() == "Sub-task") {
// the name of the field to check
final String fieldName = "Parent Issue"
// user that will make updates
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// check if a right field was updated
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find
{it.field == "Sub-task"}
if (change) {
def issueManager = ComponentAccessor.getIssueManager()
// get components of parent issue
def components = issue.getParentObject().getComponents()
issue.setComponent(components)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
} else return
} else return

1 answer

0 votes
Patrice
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.
Jan 09, 2023

Hi,

We have the same behavior simply implemented with Automation for Jira.

For this kind of action, we are using more and more Automation for Jira instead of creating our own scripts in scriptRunner.
Regarding automation and jobs, we keep Scriptrunner for advanced uses only.

So if you have a recent version of Jira DC, or using Jira Cloud, you may take a look to Automation for Jira. 

If any reader have some experiences to share, I will be glad to know how you use Automation for Jira VS Scriptrunner for this kind of job.

 Cheers

Hi @Patrice ,

Thanks for the opinion, definitely I would have gone for the  automation for Jira But Right now we are not using it.

It would be great if you help me out with the Scrip runner.

NealC
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Sep 20, 2023

I am new to automation, do you have the details on the setup you have used? Thank you

Hi @NealC 

I have Used this in my JIRA Server.

I am using Script runner 6.16.0

Any Other Details You Need Please Explain ?

Thank You.

NealC
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Sep 20, 2023 • edited

Thanks I managed to figure it out with Automation. I think the best way to do this (from what I know) is when a component field changes it will update the sub-task components. I wanted to avoid any general editing also triggering the update (eg. just changing some text in a description field for example). I probably should check to see if the component being changed is for a Story or Task... but this should be fine for now. Thanks for replying straight away

component updates.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events