Create
cancel
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

How to get data from a Scriptrunner scripted field?

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

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.

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!

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
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

886 views 2 22
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