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

Using scriptrunner and a post function to update subtasks

Dan Levine September 25, 2018

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

Suggest an answer

Log in or Sign up to answer
0 votes
Joanna Choules
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.
October 1, 2018

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

Dan Levine October 1, 2018

Thank you very much Jake!

 

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

 

Really appreciate it!!!

Dan Levine October 8, 2018

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

Thanks in advance!

Joanna Choules
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.
October 17, 2018

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

TAGS
AUG Leaders

Atlassian Community Events