You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.