Making fields mandatory during workflow transition but based on some conditions

Vidhya Mohan
Contributor
February 27, 2020

Hello,

I want to make the following fields mandatory  when bug is moved from In Progress to 'Fixed' or 'To Deploy'

Fields to be made mandatory - '1st stage of injection, Dev RCA, Dev Preventive Action, Root Cause Release

Condition when it has to be made mandatory - 

Established Root Cause is 'Design' or 'Development' or 'Same root cause' or 'Requirements' AND
Detected in Test Stage IN (5-Warranty or 7-Prod) AND
Application IN ("AAA", "BBB", "CCC")

I wrote the below code and placed it in the 'Validators' sections during the transition In Progress to Fixed. But nothing seems to be happening. can someone tell me what is wrong? 

 

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueFactory
import com.atlassian.jira.project.ProjectManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import java.util.ArrayList;
import groovy.transform.BaseScript
import java.lang.Object;
@BaseScript FieldBehaviours fieldBehaviours
FormField rootCause = getFieldById("customfield_18311")
FormField testStage = getFieldById("customfield_18308")
FormField application = getFieldById("customfield_18323")
FormField injectionStage = getFieldById("customfield_18400")
FormField preventiveAction = getFieldById("customfield_18401")
FormField devRCA = getFieldById("customfield_18408")
FormField rootCauseRel = getFieldById("customfield_18328")

if ((rootCause.getValue() == "Design" || rootCause.getValue() == "Development" || rootCause.getValue() == "Requirements"|| rootCause.getValue() == "Same root cause") &&

(testStage.getValue() == "5-Warranty" || testStage.getValue() == "7-PROD") &&

(application.getValue() == "MCOM" || application.getValue() == "OES" || application.getValue() == "NPS"|| application.getValue() == "PNI"|| application.getValue() == "WWS" ||
application.getValue() == "WSL" || application.getValue() == "COB" || application.getValue() == "COB-RT" || application.getValue() == "BOL" || application.getValue() == "CACS" ||
application.getValue() == "CBP" || application.getValue() == "SHE" || application.getValue() == "AIA" || application.getValue() == "MIB" || application.getValue() == "MIBA" ||
application.getValue() == "PTE" || application.getValue() == "PTEPLUS" || application.getValue() == " ARE" || application.getValue() == " AREPL" || application.getValue() == "CTE" ||
application.getValue() == "OHE" || application.getValue() == "IPAP" || application.getValue() == "ISIS"))
{injectionStage.setRequired(true)
preventiveAction.setRequired(true)
devRCA.setRequired(true)
rootCauseRel.setRequired(true)
}
else
{injectionStage.setRequired(false)
preventiveAction.setRequired(false)
devRCA.setRequired(false)
rootCauseRel.setRequired(false)
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events