I have a transition screen that will display customfield2 for edit based upon the value of customfield1 (set on same transition screen). I am using java script in the description to do this.
I would also like to make customfield2 required if customfield1 is set to a certain value. I have tried doing this via a simple validation using groovy runner. This works in test mode, but in groovy runner test mode, the values have already been set and stored in the database. When I try it as a workflow validator, this does not work. I suspect that because the values have not been stored yet, the condition does not validate in the same way. Here is the logic:
cfValues['customfield1'].getValue() != 'Duplicate' && !cfValues['customfield2']
I need to validate the values that have been set on the screen before they are saved. How would I go about doing that (in groovy runner or another plugin, behaviors perhaps)?
Indeed Behaviour plugin is meant for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The fields edits were only allowed to be made via a workflow transition, so I used the following groovy script as a validator:
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
log = Category.getInstance("com.onresolve.jira.groovy.rejectValidation")
log.debug("In Validator groovy script")
MutableIssue issue = issue
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
String cfRejectReasonId = "customfield_10122"
String cfRejectDetailsId = "customfield_12030"
CustomField cfRejectReason = customFieldManager.getCustomFieldObject(cfRejectReasonId)
CustomField cfRejectDetails = customFieldManager.getCustomFieldObject(cfRejectDetailsId)
cfVal1 = issue.getCustomFieldValue(cfRejectReason).toString()
cfVal2 = issue.getCustomFieldValue(cfRejectDetails)
if ((cfVal1.compareTo("Duplicate") != 0) && cfVal2 == null) {
invalidInputException = new InvalidInputException("Customer Facing Reject Details is required when the Reject Reason is set to " + cfVal1)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.