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

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

Scriptrunner - Values written to a ticket via groovy script don't seem to persist.


I have a strange issue with a script I wrote to take some data from somewhere, and add it to the summary and description field of a new issue on creation. (Note, the api URL I'm using in the example below is just for testing - just an easy API to get data back from)


I'm guessing my problem is with the "" method. Maybe I'm missing a parameter, or maybe I shouldn't even be using this method (it shows as deprecated in IntelliJ IDE). I'm just not sure what the "right" way is to store the new summary and description.


What happens is very strange. If I create the new ticket while I'm on the "Open Issues" page for my project, it all appears to work. If I refresh, that new ticket shows up, but it has the junk data that I typed in manually to the summary field. If I click once on that new ticket to view all the details about it, the summary gets updated at that point to have the data that my script is placing in it.

If I refresh - it all happens again - starts off with initial summary data - click on it, then it gets the real data.




Here's the script - it's running based on a Script listener, that triggers on issue creation and issue update:

import com.onresolve.scriptrunner.runner.util.UserMessageUtil

import com.atlassian.jira.ComponentManagerimport com.atlassian.jira.issue.Issue;

import com.atlassian.jira.issue.IssueManager;

import com.atlassian.jira.issue.MutableIssue;

import com.atlassian.jira.component.ComponentAccessor;

import com.atlassian.jira.issue.CustomFieldManager;

import com.atlassian.jira.issue.fields.CustomField;


def heatTicketFieldId = "customfield_10404"

def apiUrl = ""


//set issue variableIssue issue = issue;

//Get heat ticket number from custom field
def issueManager = ComponentAccessor.getIssueManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def heatTicketField = customFieldManager.getCustomFieldObject(heatTicketFieldId)

def heatTicketNumber = issue.getCustomFieldValue(heatTicketField)


//if heat ticket field has a value, look it up, if not, return nothing.

if(heatTicketNumber == null){




def completeUrl = apiUrl + "/" + heatTicketNumber

def connection = completeUrl.toURL().openConnection()


connection.doOutput = false


def ticketContent = connection.content.text

def newSummary = "HEAT Ticket:" + heatTicketNumber

def newDescription = "Ticket content: " + ticketContent



UserMessageUtil.success("Created JIRA ticket " + issue.key + " from HEAT ticket " + heatTicketNumber)}




1 answer

Hey Dan,

in all of our problems, where an issue would not show updated values we used the IssueManager function

  • updateIssue

    Issue updateIssue(ApplicationUser user,
                      MutableIssue issue,
                      EventDispatchOption eventDispatchOption,
                      boolean sendMail)
    This method will store the provided issue to the JIRA datastore.

    The issue will be saved and re-indexed unless EventDispatchOption.DO_NOT_DISPATCH is specified. This method performs no permission checks.

    This method should be used if you want to exert more control over what happens when JIRA updates an issue. This method will allow you to specify if an event is dispatched and if so which event is dispatched, see EventDispatchOption. This method also allows you to specify if email notifications should be send to notify users of the update.

    user - who is performing the operation
    issue - the issue to update
    eventDispatchOption - specifies if an event should be sent and if so which should be sent.
    sendMail - if true mail notifications will be sent, otherwise mail notifications will be suppressed.
    the updated issue.
    IssueFieldsCharacterLimitExceededException - when issue fields exceed the jira character limit

(Function Reference from

Thanks for the info. I got it working in a similar way, but I used IssueService instead.



IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
//Setting Issue Input Parameters

IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(currentUser, issue.getId(), issueInputParameters);

if(updateValidationResult.isValid()) {
IssueResult updateResult = issueService.update(currentUser, updateValidationResult);


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

78 views 1 6
Read article

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