How to get data from a Scriptrunner scripted field?

Rich Scire July 4, 2021

I've created a Scriptrunner scripted field called Parent Issue Key. The value is displayed correctly and I can search for values in the field with JQL. How do I get the data for the field out? I can't display it in the result of JQL search, The REST API for getting an issue doesn't have the value. This field is used for integration with other processes, is there any way to retrieve the value?

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2021

If you can search for it with JQL in Cloud, then that means the field is fully functional and should be available in search and REST automatically.

I think we need to delve into the exact configuration of the field.  What does it look like (what's its "type") when you look at the list of custom fields?  What is the script writing into it, and is there a re-index trigged when the script runs?  That sort of structural data is what you and we need to be looking at to debug this sort of thing.

Rich Scire July 4, 2021

Here is the and the script contents and configuration. I don't trigger a reindex. The return data from rest/api/3/issue/TEST-250?expand=names doesn't show a field with the name of the scripted field or the value I know it to have.

// Configuration
// Field Name: Parent Issue Key
// Location: Issue sidebar
// Project/s: All
// Issue Type/s: All
// Field Type: Text field
// Search Term: ParentIssueKey

String SCRIPTNAME = "Parent Issue Key field"

def issueKey = issue.key
def issueType = issue.fields.issuetype.name
def isSubTask = issue.fields.issuetype.subtask

def parentKey = 'No parent'

if (isSubTask) {
parentKey = issue.fields.parent.key
} else if (issueType == 'Epic' || issueType == 'Theme' || issueType == 'Initiative') {
// Parent Link
try {
parentKey = issue.fields.customfield_21227.data.key
} catch (Exception ex) {
}
} else {
// Epic link
try {
if (issue.fields.customfield_11402 != null) {
parentKey = issue.fields.customfield_11402
}
} catch (Exception ex) {
}
}

return parentKey

Thanks!

Rich Scire July 5, 2021

I looked into adding a reindex to my script but according to https://community.atlassian.com/t5/Jira-questions/Unable-to-re-index-in-JIRA-Cloud/qaq-p/788960 and https://community.atlassian.com/t5/Jira-questions/Can-t-re-index-Jira-Cloud/qaq-p/613607 user triggered reindexing is not avialabler. 

I also see that there are many reports of configuration changes not being done in a timely manner. 

What do you suggest?

Suggest an answer

Log in or Sign up to answer