Hi guys,
I'm looking for a way to create a select list using the values of JQL search.
The JQL is different between issues and will be based on the value of another field of the issue.
I'm looking for a way to convert a scripted field to select list , plugin who does it or any other idea.
Will appreciate any help.
Thanks,
Noga.
Community moderators have prevented the ability to post new answers.
For a ScriptRunner solution, that is what select list conversions are for...
Im running a server side script on a select list field that will his value is important for the JQL.
The problem that if I change the value in the edit screen, the converted field is not being updated. Only after re-enter the edit screen in the second time.
This is my script:
import com.atlassian.jira.project.version.Version import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours fieldBehaviours def formField = getFieldById(getFieldChanged()) def project = formField.getValue() def jqlSearchField = getFieldByName("text field 2") if (project) { jqlSearchField.setReadOnly(false).setDescription("Select an issue in the ${project} project") jqlSearchField.convertToSingleSelect([ ajaxOptions: [ url : getBaseUrl() + "/rest/scriptrunner-jira/latest/issue/picker", query : true, data : [ currentJql : "project = ${project} ORDER BY key ASC", label : "Results for issues in ${project} project", ], formatResponse: "issue" ], css : "max-width: 500px; width: 500px", ]) } else { jqlSearchField.setReadOnly(true) }
Thanks,
Noga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what version of ScriptRunner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So when you change the project field the search results don't change?
Have you put this script on the project custom field (maybe you put it on the initialiser, which only runs at form load)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it doesn't change immediately, only after I click "done" and re-enter edit screen.
I've tried using the following script as an initialiser and now don't get results at all.
import com.atlassian.jira.project.version.Version import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours fieldBehaviours def formField = getFieldById("customfield_10703") def project = formField.getValue() getFieldByName("text field").convertToMultiSelect([ ajaxOptions: [ url : getBaseUrl() + "/rest/scriptrunner-jira/latest/issue/picker", query: true, // keep going back to the sever for each keystroke // this information is passed to the server with each keystroke data: [ currentJql : "project = ${project} ORDER BY key ASC", label : "Test Noga Pick high priority issue in Support project", showSubTasks: false, // specify maximum number of issues to display, defaults to 10 // max : 5, ], formatResponse: "issue" ], css: "max-width: 500px; width: 500px", ])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I said, don't use an initialiser, you need to add this to the customfield_10703 field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe what Jamie means is that your script needs to be associated with the custom field in the behaviour's configuration, rather than being in an initialiser function. For example, in the screenshot below, the script is associated with the Assignee field, and no initialiser is defined.
Screen Shot 2016-09-28 at 10.32.47 AM.png
Specifying the custom field with getFieldById(
"customfield_10703"
)
still won't work if it's done in an initialiser function.
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.