Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,869
Community Members
 
Community Events
184
Community Groups

Set assignee to "Unassigned" in workflow screen using Scriptrunner Behaviours

Edited

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:

  • create a behaviour "Reset Assignee"
  • set up a mapping to my test project
  • set up an initialiser function (based on a script I found in a forum)

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

1 answer

0 votes
Steve Thornhill
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 24, 2022

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".

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events