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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Adding a comment when a custom field changes to a certain value

Honestly not really sure where to start here. Had a look at writing a custom listener but wasn't sure how to get context for the issue. The listener would need to rigger on CustomFieldUpdatedEvent events and add a comment to the issue that contained the assignee and the current user. The customfield is a single choice dropdown list and I only want the comment added when it is set to a specific value. Any help would be greatly appreciated! Thanks

1 answer

Hi Charles,

Have you looked into solution like Automation for Jira ?


Thanks for a quick reply.

Looked into it yes, however, I already have a scriptrunner license and set up (with some other scripts) so I was looking for a way of achieving this with scriptrunner as well.

Hi Charles,

I've just found this script from Aidan Derossett on another Community post (

It might help.

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

//Grab necessary components
def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager
def cfm = ComponentAccessor.customFieldManager
def commentManager = ComponentAccessor.commentManager

//Get the project you wish to run this script on and retrieve all of the relevant issues
def projectID = projectManager.getProjectByCurrentKey("Project Key").id
def issueIDs = issueManager.getIssueIdsForProject(projectID)
//Get logged in user that will act as the commenter
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

//Go through every issue ID and transfer the desired text custom field to a comment
    def currentIssue = issueManager.getIssueObject(it)
    def currentCustomField = cfm.getCustomFieldObjectByName("Custom Field Name")
    def currentCFValue = currentIssue.getCustomFieldValue(currentCustomField)

    //Check for null custom field on the current issue
        //define the comment
        def valueToComment = "$ \n $currentCFValue"

        //Add the comment to the issue, delete the custom field value, and persist those changes to the DB
        commentManager.create(currentIssue, loggedInUser, valueToComment, true)
        currentIssue.setCustomFieldValue(currentCustomField, null)
        issueManager.updateIssue(loggedInUser, currentIssue, EventDispatchOption.ISSUE_UPDATED, false)


Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you