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

This widget could not be displayed.

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.

This widget could not be displayed.

     

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

513 views 3 18
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