Good afternoon,
I was given a request asking for the customfield (select list (single choice)) to become (multiple choices) for two issue types, and for all others to remain single choice. Could someone tell me if this can be done using Scriptrunner Behaviours and how?
I've seen methods like convertToMultiSelect and others, but have a problem with understanding how they work and how to make a multi-select choices from single choice.
At the moment the view screen shows one value (screenshot_1), when editing the field becomes multiple choices (screenshot_2), but when saving all values, only the last value remains in the field (screenshot_3).
Hi @Volodymyr
To answer your question, yes, you can do this by converting a Single-Line Text Field to either a Single-Select List or a Multi-Select List. You will need to use ScriptRunner's Behaviour and the Select List Conversion, i.e. use either the convertToSingleSelect or convertToMultiSelect option depending on your requirement.
Please refer to this ScriptRunner Documentation for more information and examples.
In regards to converting it to either single or multi-select based on the issue type, you will need to use the Behaviour Initialiser and use the issueContext to control the conversion, i.e. something like:-
if (issueContext.issueType.name == 'Bug') {
getFieldByName("TextFieldB").convertToMultiSelect([ // <1>
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/githubRepoQuery", // <2>
query : true, // keep going back to the sever for each keystroke
minQueryLength: 4, // <3>
keyInputPeriod: 500, // <4>
formatResponse: "general", // <5>
]
])
} else if (issueContext.issueType.name == 'Story') {
getFieldByName("TextFieldB").convertToSingleSelect([ // <1>
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner/latest/custom/githubRepoQuery", // <2>
query : true, // keep going back to the sever for each keystroke
minQueryLength: 4, // <3>
keyInputPeriod: 500, // <4>
formatResponse: "general", // <5>
]
])
}
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
I read the documentation and my question still remains - How to convert select list-single choice to select list-multiple choices.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr,
Based on what condition do you want to do the conversion?
If it's based on the issue type, I have already answered it in my previous comment.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
I see a method for converting the field and the conditions under which the code is executed, but I can't save more than one value and values are only displayed in the Edit Screen.
I can't understand how the code should work and what should be written in the end.
The field allows me (due to the method "convert") to select more that one value, but only keeps the last one when saving, so I can't figure out what I need to do to avoid it.
I've tried your code, but it doesn't change anything, so I don't know exactly where to change it.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.