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?
Sort of found an answer:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
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)
def comment = getFieldById("comment")
comment.setRequired(true)
This will make the field change to yes, and require the comment field.
What I can't figure out... How to ONLY pop up the comment field, and not the entire Edit screen - if this is possible...
Hi lukec,
Behaviours only work on forms. Whenever a field is configured in behaviour, it will force the edit screen to come up instead of just inline editing. This is because behaviour only works there.
To answer your question, no this is not possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks.. I'm now making another behaviour, for a different custom field.. and when I run it, it seems to also apply to the initial behaviour. i.e :
I have one behavior to change CF 'Security review' to Yes, and requires a comment.
I have another behaviour that changes CF '3x' to Yes, and requires CF 'ProdCat' to be filled in.
When I go to change CF 3x, it is also updating Security review. Do you know why?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.