Hello,
I am trying to code a select list picker scripted field using scriptrunner (jira dc v9.12.2 and scriptrunner v 8.19.0).
My tests are working fine but it looks like the values proposed in the list are not kept up to date with the csv file located on my jira server
Here is my code:
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption
import groovy.json.*
String filePath = '/pathtomyfile/monfichiercsv.csv'
//Reading the csv file as an inputstream
List csvMapList = []
new File(filePath).withInputStream { file ->
log.info(file)
file.eachLine { line ->
def tmpMap = [:]
tmpMap.putAt("value", line.toString().toLowerCase())
csvMapList.add(tmpMap)
}
}
search = { String inputValue ->
csvMapList.findAll {it ->
it.'label'.toLowerCase().contains(inputValue.toLowerCase())
}
}
toOption = { Map<String, String> map, Closure<String> highlight ->
new PickerOption(
value: map.value.toString(),
label: map.label.toString(),
html: highlight(map.label, false),
)
}
getItemFromId = { String id ->
def selectedOption = csvMapList.find {it.value.toString() == id }
if (selectedOption) {
selectedOption
} else {
null
}
}
renderItemTextOnlyValue = { Map item ->
item.'label'.toString()
}
This works more or less fine, but since I basically want to maintain the values from the list up to date according to the csv file, I tried updating it, expecting that the "inputsteam" will open and read the csv each time the field is opened for selection.
Well it turns out it is not the case and the values only appears to be updated whenever I "edit" the scripted field and do an update.
How to explain this and how to solve my issue?