How to change a custom field when a jira issue updated?

I need to make a trigger that would update a custom field to a certain value every time when the issue updated.  I'm using Adaptivist ScriptRunner on JIRA v 6.4.11. I created a new listener using the menu: JIRA Administration > Add-ons > Script Listeners.  I chose "Fast-track transition an issue" and then used these values for its attributes:

Events set to: "Issue Updated"

Condition set to: isUserMemberOfRole('Administrators')

Action set to: Start Progress

Additional issue actions: issueInputParameters.setComment('Write your comment here')


The code above (in the additional issue actions) was generated when I clicked on the link "Add example: Add Comment". 


However, the last step does not work. I'm an admin and once I edit a ticket, I see that this listener makes it "IN PROGRESS" instantly but it never adds a comment. Please advice.

1 answer

Hi Stanislav,

I have just tested replicating your issue localy on my JIRA 6.4.12 instance using Script Runner version 4.1.3.9. I get the same behaviour as yourself where the issue transitions to In Progress without a comment when I set the Additional Actions using the example code provided.

However I am able to add a comment if I use the following the code below in the Additional actions box of the Fast Track listener.

import com.atlassian.jira.component.ComponentAccessor

// Get the Comment Manager and current logged in user
def commentMgr = ComponentAccessor.getCommentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()

// Add a comment to the issue
commentMgr.create(issue, user, "commentBody" , true)

 

I hope this helps.

Thanks

Kristian

Thanks Kristian. But please don't raise the ticket. JIRA will only create the comment if there is a screen with a comment on. skipScreenCheck should avoid this requirement, but it doesn't work. Search jira.atlassian.com for that.

Thank you. it worked fine.

Hi Stanislav,

Glad we were able to help.

If this issue is useful can you please mark it as accepted so that other users with similar questions can easily find it in future.

Many Thanks

Kristian

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

113 views 0 3
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