Jira does not refresh a scripted custom field even when the links to calculate this scripted field

Anthony Hawkins January 3, 2018

Jira does not refresh a scripted custom field even when the links to calculate this scripted field have been modified. It seems that when you clone an issue with a scripted custom field, you can not modify it. So my question is how do you modify a scripted field on on a Jira issue? Do you use REST API or write a groovy script to modify it?

2 answers

0 votes
Steven F Behnke
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.
January 3, 2018

Disable the caching on the scripted field. This is basically required when scripting a field that 'talks' to linked issues.

https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html#_more_advanced_notes_on_caching

enableCache = {-> false}
Vineela Durbha September 13, 2020

@Steven F Behnke 

I have added the above value but it still doesnt work. Any other way to make it work?It displays old value and only gets refreshed after updating the request

0 votes
Alexey Matveev
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.
January 3, 2018

Hello,

Do you mean Scriptrunner Scripted Field? If so, then Scripted Fields do not store any value. There is a script inside the field which produces a value. I guess you need to change the script. Go to cog item->add-ons->scripted fields. Then find your field and choose edit. You will be able to change the script.

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.
January 3, 2018

If it helps, there's an oversimplified way to think of it. 

The fields are read-only because they are calculated, not entered.  A scripted field's data is updated when the issue the field belongs to is re-indexed for any reason.

You can't modify the values of a scripted field because they don't really exist.

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 3, 2018

Nic, I forget, does the value of a scripted field usually depend on the cached data for the issue or what is in the Lucene index? I think it might be the former

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.
January 3, 2018

Mostly the cached value.  It sees the Lucene index as the "source of truth", but in most cases looks for the cached value before reading the index.

(This is a lot of the reason I say "oversimplified" when I say "scripted fields are calculated when indexing")

Like Srikanth Ganipisetty likes this

Suggest an answer

Log in or Sign up to answer