I am using Scriptrunner 6.20.0 and I have converted a text Field to a SingleSelect and it displays fine, plus I can select an option in the form. Just what I wanted.
def tribeField = getFieldByName("Tribe")
tribeField.convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/...",
query : true,
formatResponse: "general"
]
])
The problem is that I cannot set a value in the field programmatically.
"tribe1" is one of the values returned from the REST endpoint, and I have tried many things, before or after calling convertToSingleSelect, like:
tribeField.setFormValue("tribe1")
tribeField.setFieldOption(["tribe1": "tribe1"])The second line sets an option in the hidden input HTML element, which is not valid:
<input class="text full-width-field" type="text" name="customfield_20208" id="customfield_20208" aria-labelledby="customfield_20208-label customfield_20208-helper" style="display: none;">
<option value="tribe1">tribe1</option>
</input>
This is exactly my problem, but the answer did not help at all: https://community.atlassian.com/t5/Answers-Developer-Questions/Set-value-on-text-field-converted-to-select-list-with/qaq-p/548053
Any ideas?