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

1 vote
Accepted answer

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 Sign up to answer
Community showcase
Published Monday in Jira Service Desk

Frequently Asked Questions for Jira Service Desk (AKA JSD FAQ)

Just the FAQs! Welcome to the Community, and this Focused-FAQ! Here, we've pulled together some of the most frequently asked questions associated with Jira Service Desk (JSD). We hope ...

137 views 0 11
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