Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

scriptrunner when creating subtask using customfield

Chax
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 27, 2019

hi, I am using select list(cascading) type custom field to trigger the script below. I only want it to validate the first field value. I only want Mpower - MOBILE and Mpower - WEB as my trigger, but when I included 2nd value, it is not creating subtask. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Logger
import org.apache.log4j.Level

def cf_name = customFieldManager.getCustomFieldObjectByName('Product (New)') as String
def x = issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product (New)")) as String
if(
x in ["[null:Mpower - WEB, 1:PowerForm - 3.3.3]",
"[null:Mpower - WEB, 1:PowerForm - 3.3.2]",
"[null:Mpower - MOBILE, 1:WorkForce - 1.10.17]",
"[null:Mpower - WEB]",
"[null:Mpower - MOBILE]"] && issue.getSubTaskObjects().size()==0)
{
return x
}

 the 2nd field is the version, and there are atleast 35 of it. if I included it on the the script, and there's a new release, I will need to update it.

any work around?product.png

1 answer

0 votes
Carmen Creswell [Adaptavist]
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.
January 30, 2019

Hi Chax, 

How are you using this script? For example, are you using it in Behaviour, a Post Function, etc? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events