Hi,
Using the rest end point and behaviour scriptrunner i was able to convert a text field into dropdown list which fetches the values using rest call. As in the link: https://scriptrunner.adaptavist.com/4.3.6/jira/behaviours-conversions.html#_walkthrough_external_rest_service
Script used:
getFieldByName("textfield").convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/query1",
query: true,
formatResponse: "general"
]
])
This works perfectly.
I want the same functionality with single select list field.
i am trying with below script,
getFieldByName("selectlist").setFieldOptions([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/query1",
query: true,
formatResponse: "general"
]
]) .
The field displays [Object Object].
How to display the options in the select list field?
The select list field has no values configured in jira. The list has to take the value only from the rest call. When using setFieldOptions the list field only shows
This is not possible. Single Select field and Multiselect field store a relational "option" id in the database. So that option must exist for a given issue context (project and issue type).
setFieldOptions will only let you control which of the existing options should appear in the select field.
If you want values from a rest call, you can only do that with a text field.
Our approach was to create a new text field to replace the old select, write a fairly complex and custom script to update all issues with a select value into the text field then retire the select field.
Report and dashboard that were based on the old select fields had to be identified and fixed to use the new text field (with single select conversion).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share your complete script for text field using rest api? I’m planning to use this ServiceNow integration.
Appreciate your help on this
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @G Krithica
Using behaviour module it's possible to use setFieldOptions to set the value for a select list type of field
But using this you can't modify the existing values of the custom field present on the server. To do that you will need to use script runner plugin java server side code exposed as a REST endpoint.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The select list field has no values configured in jira. The list has to take the value only from the rest call. When using setFieldOptions the list field only shows [Object Object].
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @G Krithica
Could you elaborate on
The list has to take the value only from the rest call
Because the method setFieldOptions is for setting the values based on already existing values of the custom field but if there are no values of the custom field then setFieldOptions will always no values to set. Hence the custom field on the server has to have values in order for setFieldOptions to set values.
see example here
it's setting values based on existing values of the custom fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @G Krithica
If the answer helped you, please accept/upvote the answer so that others are helped as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.