Missed Team ’24? Catch up on announcements here.

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

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

Dan Conroy March 15, 2018


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 "issue.store()" 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 = "https://api.macvendors.com"


//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

Suggest an answer

Log in or Sign up to answer
1 vote
Deleted user March 15, 2018

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 https://docs.atlassian.com/software/jira/docs/api/7.8.0/com/atlassian/jira/issue/IssueManager.html)

Dan Conroy March 19, 2018

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);

AUG Leaders

Atlassian Community Events