Hi,
I have a custom field that is single select dropdown.
When the user selects Yes, I want a pop up to require a comment.
I have basic code here:
import com.atlassian.jira.component.ComponentAccessor
def SecReviewFld = getFieldByName("Security Review")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(SecReviewFld.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "Yes" }
SecReviewFld.setFormValue(optionToSelect.optionId)
import com.atlassian.jira.issue.comments.CommentManager
def comment = getFieldById("comment")
if (SecReviewFld == "Yes") {
comment.setRequired(true)
comment.setHidden(false)
}
else {
comment.setRequired(false)
}
def defaultValue = """\
**Please leave a comment**
""".stripIndent()
if (!comment.formValue) {
comment.setFormValue(defaultValue)
}
When I click the custom field Security Review, the edit screen pops up, and it flips to Yes automatically, but the comment field is now required.
Anyone know how to do this?
