Forums

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

Help with Post Function "If" statament based on selection of Checkbox field.

Wayne Cranford March 21, 2018

Have made many other attempts since I first posted and made several tweaks along the way, but still no success getting the "If" statement to work.  I can populate the 2nd field (Resume Test?) when I comment out the if-statement in the below, but have not found how to make if-statement work.  

(1) Temp Resume Type - selection (Resume Assembly, Resume Test, Resume Shipment) - custom Checkbox field

(2) Resume Test? - selection Yes, Radio Button

Need to only populate the Resume Test? = "Yes" if the "Resume Test" is selected for the Temp Resume Type  field. The reason is I need this is the Temp Resume Type is a temporary field that could be changed, but we need to make additional actions later if at any time a "Resume Test" was selected.  

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfig

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf1 = customFieldManager.getCustomFieldObjectByName("Resume Test?")
def fieldConfig1 = cf1.getRelevantConfig(issue)

def value = ComponentAccessor.optionsManager.getOptions(fieldConfig1)?.find { it.toString() == 'Yes' }

if (['Temp Resume Type']*.value.contains("Resume Test")) {

issue.setCustomFieldValue(cf1, value)
}

 

Thanks

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events