I'm trying to set the field "Assignee" to "Unassigned" during opening a workflow transition screen. The reason for this is, that the user that executes the transition must assign the issue to a user that should do the next work on this issue.
To achieve this, I did:
This is the initialiser script:
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours
import static com.atlassian.jira.issue.IssueFieldConstants.UNASSIGNED_STATUS
@BaseScript FieldBehaviours fieldBehaviours
final String screenName = 'DEV Workflow Screen (2022)'
final String fieldName = "Assignee"
final String expectedValue = UNASSIGNED_STATUS
if (fieldScreen.name == screenName) {
def field = getFieldByName(fieldName)
log.warn "Try to set Assignee field to: " + expectedValue
log.warn "current Assignee: " + field.value
field.value == expectedValue ? field.clearError() : field.setError('This is not a valid value')
log.warn "Assignee set to: " + field.value
}
If I execute the workflow step, my transition screen opens and shows the defined error message below the assignee field. The log shows:
Assignee set to: fwinkler
current Assignee: fwinkler
Try to set Assignee field to: Unassigned
all lines with this prefix: "2022-03-24 10:53:40,053+0100 http-nio-8081-exec-43 url: /rest/scriptrunner/behaviours/latest/validators.json; user: fwinkler WARN fwinkler 653x18079188x1 zpj9g 172.29.241.147,0:0:0:0:0:0:0:1 /rest/scriptrunner/behaviours/latest/validators.json [c.o.scriptrunner.runner.ScriptBindingsManager]"
Any help would be highly appreciated.
Frank
This doesn't answer your query on the function of behaviours, but couldn't you achieve the same function by just using a validator on the workflow to check that Assignee has been changed?
Thanks Steve! I also thought of a validator at first. But the requirement is that the assignee should be set to "unassigned" when the transition screen is opened (and only in the screen's field). If I use a validator, I would set the assignee in the issue - and when the user closes the transition screen with Cancel it would stay "unassigned".
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.