I have a custom text field (Release Note description) which must be set as required field when issue is resolved and if another custom field (Release Note) value is "Required". Below is the current script I wrote as a post function on issue resolution and currently it shows error on releaseNoteDescField.setRequired(true)
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def releaseNoteField = customFieldManager.getCustomFieldObject("customfield_xxxx")
def releaseNote = issue.getCustomFieldValue(releaseNoteField)
def releaseNoteDescField = customFieldManager.getCustomFieldObject("customfield_xxxx")
def releaseNoteDescription = issue.getCustomFieldValue(releaseNoteDescField)
if (releaseNote == "Required") {
releaseNoteDescField.setRequired(true)
}
Hi @Raj Alagappan , welcome on the community. It seems to me you are mixing more things together
You definitelly cannot use postfunction to validate anything. Postfunction just executes some code or operation after the information on transition are validated. So you can use
Hope, it helped. And if not, feel free to ask..
Hi @Martin Bayer _MoroSystems_ s_r_o__ Thanks a lot for the response. My requirement is to validate a custom field value and based on it set another custom field as required. What would be the best solution (validator, behavior or post function) for my problem? I guess I cannot use validator as it can validate but not set custom fields. The reason I did not go with behaviors is I thought it is not efficient as I want this to happen only when issue is Resolved but setting up a behavior will get triggered irrespective of the workflow and not just when issue is Resolved. But behavior is the only way to go here I can setup a behavior and add another condition to check if issue status = "Resolved"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Raj Alagappan, if you use validator, the flow will be
You can use Behaviour ofcourse, it can be configured for single transition (action) as described here: https://docs.adaptavist.com/sr4js/latest/features/behaviours/behaviours-examples/require-comment-for-action
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.