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

Using scriptrunner and a post function to update subtasks

Hello

We have a bunch of post functions on a workflow that creates sub-tasks. It's working perfectly but what we are looking to do is create a Modify workflow. So if someone wants to modify the parent ticket it will automatically reopen any subtasks that are completed, push all of the custom field values to the subtasks and modify the summary of each of the subtasks with a MODIFIED prefix.

Can someone point me in the right direction on how to accomplish this easily?

Thank you so much in advance!

Dan

1 answer

Hi Dan,

If you want the actions to be triggered on any update of the parent, rather than transitions only, then you will want to use a custom script listener on the Issue Updated event.

To update each of the child issues you should probably be able just to use a single IssueService action per issue, namely the transition action. You can update the custom field values and summary at the same time by passing their new values to the IssueService via the IssueInputParameters: the service will perform the transition and update in one go, the same as if you had edited the field values on the transition screen before submitting.

Let me know if you need me to expand on any of the above, I'm happy to write some example code although it may take me a little longer.

J

Thank you very much Jake!

 

Some example code would be amazing and definitely help us tremendously!

 

Really appreciate it!!!

Hi Jake! Just following up to see if you had any time to give some examples.

Thanks in advance!

Hi Dan,

Apologies for the delay in getting back to you. Here is an example of how to transition an issue while updating its summary and a custom field value. Note that the custom field value needs to be provided as a string irrespective of its type: the correct formats for doing this are detailed in the Atlassian documentation.

import com.atlassian.jira.component.ComponentAccessor

def is = ComponentAccessor.issueService
def u = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issue = ComponentAccessor.issueManager.getIssueObject("ISSUE-6")
def iip = is.newIssueInputParameters()
iip.summary = "MODIFIED " + issue.summary
iip.addCustomFieldValue(10033, "30/Dec/05 5:35 PM")
iip.skipScreenCheck = true
def vr = is.validateTransition(
u,
issue.id,
5,
iip
)
is.transition(u, vr)

J

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Partner Webinar Opportunities: January 2022

Hi everyone 👋, I really like the format of the webinar opportunities summary that @Jimmy Seddon posts monthly on the Welcome Centre group. It's a great place to go to check that you didn...

148 views 3 11
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