Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Async Scripted Fields in JIRA

John Miller April 26, 2019

We require information from outside systems in our JIRA and Service Desk issues. The following script works fine:

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper

def http = new HTTPBuilder('http://example.com/api/product/' + getCustomFieldValue("Product ID"))
http.request(GET) {
requestContentType = ContentType.JSON
response.success = { res, JSON ->
return JSON.ProductWarrantyStatus
}
response.failure = { res ->
return "Error: ${res.status}"
}
}

However our needs from this system are growing and we need to make multiple requests this way; it is slowing each page load down noticeably, and each scripted field that I add slows it down even more.

How can I make these fields asynchronous, so that the requests load AFTER the JIRA issue details page loads?

1 answer

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2019

Since the scripted field are calculated server-side before the web-client receives the issue object, I don't think that what you are asking can be done. No data is ever stored in the db.

To load field value asynchronously while the user is working on the issue would need to all happen on the client-side. 

You may want to re-think your integration. Instead, I would recommend having regular custom fields and use scriptrunner to update the stored value for the fields.

Ideally, your other system would take care of pushing those updates to Jira just when that data changes.

But if that's not possible, you would have to either update the issues in the background on a schedule or using a manual trigger from the users (think global workflow transition ).

In theory, you could write custom javascript deployed via Scriptrunner Web Fragment that would fetch and update the field when an edit screen is open.

Suggest an answer

Log in or Sign up to answer