Script postfunction not working on subtask create transition?

Hi Jamie,

we have 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])
}

 

 

 

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 

1 answer

0 vote

Make it the first post-function, if it's after "reindex..." it's too late.

script_postfnct.PNGI am sorry jamie, I will keep in mind there won't be a cross questions from next time.
I am unable to add comment in my original request,due to my other account doesn't have the eligible points.I will this account from next time onwards.
Thank you for understanding.
Please see my order of the scriptost function, but still not able set the group after the sub-task create transition.

Make it the first post-function...

Hi Jamie,

I have tired that as well and even after fire issue event also,but still no use.

Best Regards,

Sureshscript_postfnct_1.PNG

 

Don't use this:

def highlevel = demoSelect.getValue(issue)

use issue.getCustomFieldValue(demoSelect)

same for the others.

Hi Jamie,

Just to test we have added following simple script set the group.But, we are unable to set the group to the field in JIRA subtask post function.

import com.atlassian.jira.component.ComponentAccessor    def customFieldManager = ComponentAccessor.getCustomFieldManager() def groupCf = customFieldManager.getCustomFieldObjectByName("Code Approving Group") def groupManager = ComponentAccessor.getGroupManager() def group = groupManager.getGroup("jira-tech-infra-cr-application-core-approvers") issue.setCustomFieldValue(groupCf, [group])

unreadable code, it's all on one line... please make it easier for people to help.

Please find now.

import com.atlassian.jira.component.ComponentAccessor 
def customFieldManager = ComponentAccessor.getCustomFieldManager() 
def groupCf = customFieldManager.getCustomFieldObjectByName("Code Approving Group") 
def groupManager = ComponentAccessor.getGroupManager() 
def group = groupManager.getGroup("jira-tech-infra-cr-application-core-approvers") 
issue.setCustomFieldValue(groupCf, [group])

Is it a multi-group picker? If it's a single picker remove the square brackets around group. Can you check your log files too.

It is multi-group picker only.I have already enabled script logs.

This script is working fine in other transitions,It is not working only when create sub-task issue transition.

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

181 views 0 4
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