Create branch trigger bypasses post function custom script using ScriptRunner and validator

custom ScriptRunner post function on transition Start Progress shows as successful but only updates Assignee field during normal JIRA transition.  When create branch trigger executes the assingee value remains unassigned (not changing) and validator Required fields: Acceptance Criteria is also bypassed.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def Issue issue = issue

if (currentUser != issue.assignee) {
issue.assignee = currentUser
}

2 answers

Hey Anj!

So this is just a hunch at this point, but it may be that your script is being executed, but the changed asignee isn't being persisted to the JIRA database. Could you go ahead and try this code? I've made a couple of edits to ensure that the changes are indexed:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue

def issueManager = ComponentAccessor.issueManager
// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def Issue issue = issue
if (currentUser != issue.assignee) {
issue.assignee = currentUser
//Persist the assignee change to the DB
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}

 Try that script out and let me know what you find! :)

If it doesn't change anything, we may have to look a little further into the problem.

-Aidan

Hello, Aidan.  I tried the code and the record remained unassigned when I create branch but auto assigns during normal JIRA worfklow.  Thanks for trying though.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

158 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you