Script postfunction not working on subtask create transition?

Suresh April 28, 2016

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 votes
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

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

Suresh April 29, 2016

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.

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

Make it the first post-function...

Suresh April 29, 2016

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

 

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

Don't use this:

def highlevel = demoSelect.getValue(issue)

use issue.getCustomFieldValue(demoSelect)

same for the others.

Suresh May 4, 2016

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])
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.
May 5, 2016

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

Suresh May 5, 2016

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])
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.
May 5, 2016

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.

Suresh May 5, 2016

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
TAGS
AUG Leaders

Atlassian Community Events