Creating Sub-Task Automatically (Script Runner)

Matheus Fernandes July 3, 2015

Hi Team,

My name is Matheus Fernandes, I am part of JIRA Support Team from Johnson & Johnson. I am currently working to get Script Runner configured to create default sub-tasks in automatically way. However, I am not getting it done. Look what I have done:

 

  • Gone to Workflow that I want to change
  • On the creation action, added the Post Function to create the subtask, below the exactly values:
    • Condition= issue.issueTypeObject.name == 'Story' – Even removing this condition, it's not working.
    • Target Issue Type = Subtask
    • Sub-Task Summary= Sub-Task Script Runner Test
  • Then I save the change, publish the draft
  • Create the story in the project that is using the changed workflow

Following the steps above, I am not getting the expected result. Is there any thing that I am missing?


Thanks in advance!

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Udo Brand
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.
July 3, 2015

I guess it is due to your position of the create subtask post function within the other post functions. Put it below the function "Re-index an issue to keep indexes in sync with the database"

see https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Createasub-task

 

JamieA
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.
July 5, 2015

Also check the logs, and see if there are any errors.

Suresh April 28, 2016

Hi Jamie,

On added subtask script runner postfunction.

import com.atlassian.jira.component.ComponentAccessor
 
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupCf = customFieldManager.getCustomFieldObjectByName("Code Approving Group")
def demoSelect =customFieldManager.getCustomFieldObjectByName("High Level Deployment Environments")
def highlevel = demoSelect.getValue(issue)
def patch =customFieldManager.getCustomFieldObjectByName("Patch Type/s")
def patchType = patch.getValue(issue)

def groupManager = ComponentAccessor.getGroupManager()
if(issue.issueType.name=="Patch Source Core Request Sub-Task" && (highlevel.toString().contains("PROD")|| highlevel.toString().contains("BETA") || highlevel.toString().contains("DEMO") || highlevel.toString().contains("PREPROD")) && 
  (patchType.toString().contains("Code"))){
    def group = groupManager.getGroup("jira-tech-infra-cr-application-core-approvers")
    issue.setCustomFieldValue(groupCf, [group])
}
import com.atlassian.jira.component.ComponentAccessor
 
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupCf = customFieldManager.getCustomFieldObjectByName("Code Approving Group")
def demoSelect =customFieldManager.getCustomFieldObjectByName("High Level Deployment Environments")
def highlevel = demoSelect.getValue(issue)
def patch =customFieldManager.getCustomFieldObjectByName("Patch Type/s")
def patchType = patch.getValue(issue)

def groupManager = ComponentAccessor.getGroupManager()
if(issue.issueType.name=="Patch Source Core Request Sub-Task" && (highlevel.toString().contains("PROD")|| highlevel.toString().contains("BETA") || highlevel.toString().contains("DEMO") || highlevel.toString().contains("PREPROD")) && 
  (patchType.toString().contains("Code"))){
    def group = groupManager.getGroup("jira-tech-infra-cr-application-core-approvers")
    issue.setCustomFieldValue(groupCf, [group])
}

 

 

I have added below to  "Re-index an issue to keep indexes in sync with the database."

But is not working, any thing wrong in my code. I am not seeing any error in the logs.

But the script is working in other transitions, except On create transition.


Best Regards,

Suresh 


JamieA
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.
April 29, 2016

please don't cross-post Suresh

0 votes
Matheus Fernandes July 6, 2015

Thanks everyone!

 

I created the post-function "Re-index an issue to keep indexes in sync with the database" and it worked very well.

 

Best Regards,

Matheus Fernandes.

Suresh April 29, 2016

Hi Matheus,

Can it work on create subtask transition?

Thanks In Advance,

Regards,

Suresh

 

 

TAGS
AUG Leaders

Atlassian Community Events