Creating Sub-Task Automatically (Script Runner)

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

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

 

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

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 


please don't cross-post Suresh

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.

Hi Matheus,

Can it work on create subtask transition?

Thanks In Advance,

Regards,

Suresh

 

 

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,007 views 5 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot