Hi All,
I am investigating a request but I haven't found a clue so far:
we have a Jira and Confluence instance and the user management is common: it is administrated in Jira. We - admins - have a project in Jira where all the project leaders and space admins can submit issues regarding to the Jira and Confluence. Most of the time they submit access rights issues where they ask us to add the developers/testers, etc to a project and/or a space.
We have 2 custom fields in our user access issue type: one is the Confluence spacewhich contain all the existing space names as options. The other is the Jira project which contains all the existing project name as options. Both custom fields are of multi-select type.
So when a project leader requests an issue, just select in these custom fields which project(s) and/or space(s) he want to add the users.
The main problem is that the project leaders and space admins often change the name of their project or space. But the update the options of these 1 custom fields is very cumbersome!
My question is that is there a macro, script, feature which update the options of these custom fields? I mean that this feature run and make a list of the names of existing projects and spaces and updates the 1 custom fields.
Can you please suggest?
Thanks in advance!
Rumi
I'd use the Jira database values plugin, and point it at the "project" table inside the same Jira.
See https://marketplace.atlassian.com/plugins/org.deblauwe.jira.plugin.database-values-plugin
Hi Nic ,
Once i had tried to connect to Jira Database(External) using JDBV plugin but i was not able to connect it , i was able to connect to another external database .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also use the Scripted field provided by script runner plugin and write a script which will show all the projects and space in the customfields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I have Script runner plugin, so I opt this solution. Only problem that I don't know the velocity. If it's not a difficult code, can you please help to write?
Thanks in advance!
Rumi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rumi,
I have never used this feature before , but i will try to help you with the script .
First thing is to check if scripted field can be a multiselect list . Try to add a scripted field and check , refer the docs for this .
If you are able to connect to Jira & confluence database with Database values plugin you can even go for it its a free plugin .
Once i tried to connect jira db using JDVP but i was not able to and had to use SQL feed plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is it a multiselect list ? can you paste your script here ? do you see anything related to this field in the logs ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
thank you for help!
"First thing is to check if scripted field can be a multiselect list . Try to add a scripted field and check , refer the docs for this ."
It's weird...because we have Script Runner plugin but when creating a custom field there is no field type Scripted Field to choose in the list. Is there any other way to add a script to a custom field? I guess to description field...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the description only javascript work and using that we cant get spaces from confluence.
Another approach can be to set options to the multiselect field using behaviours plugin.
You will have to create a script which gets all project names and sets it as options to this field using the setFieldOptions(Map map)
Have a look at this example
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh , it means you dont have the latest compatible version of the plugin , scripted customfields are available from version 1.8.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need this version . Is it compatible with your jira version ? What version of jira u have ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see...this is the problem: we have only Jira version 4.3.4
Mizan, you mentioned the Behaviour plugin as a helpful plugin to another solution. I checked and we have this plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I try to find another solution, so I gather all the info here in this issue.
Mizan, have you got any different idea?
I summarize the need: I'd like to have a custom field type of multi-select. The options of the custom field would be the current name of all projects of the instance. So it would update the option if a project name would be changed or the options would extend if a new project were created. But when a project were deleted the option must remain.
Mizan, sorry for the disturbance!:)
Rumi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another idea would be to use Behaviours plugin , but i want to know which database your Jira uses (Oracle , MySql , etc) , How many projects in your Jira Instance ?
The Behavior plugiin cannot connect to Oracle by default , you will have to make it compatible with your version of Jira . I have done it see this https://studio.plugins.atlassian.com/browse/JBHV-133 issue.
Adding a behaviour(server side groovy script) to a multiselect customfield might help.
This behaviour will connect to Jira database , fetch all project names and display it in the field .
I have done something similar .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I think it's the right track: we have Behaviours plugin. Version: 0.4.7
We use PostgreSQL database
Current number of projects: 185, Jira version: 4.3.4
How did you do that in you Jira?
Rumi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can but behaviours and script runner are two different plugin , you wont be able to make a field behave the way you want using script runner ,
i think this is not the correct way there can be a better way , instead of getting the values from database we can directly get it through API , or if you are comfortable with plugin developement you can create a customfield which will behave like a multiselect project picker .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is sad because the main problem that I am not acquianted with plugin development.
So I'm a bit confused: where can I run this script? I only know the script runner interface.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Behaviours plugin provide a similar interface but for each field , you should go through the documentation first .https://studio.plugins.atlassian.com/wiki/display/JBHV/JIRA+Behaviours+Plugin
also see this similar example
then the next thing to do is install the plugin on a test instance then start scripting on a customfield(multiselect list type) this field will show all projects from the jira instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I installed the Behaviour plugin to my test instance.
I started the test: I wrote a script which result the members of a particular group and then inserted this script to the test behaviuor and accessed to a custom field. But when testing the cutom field doesn't contain the member list as options - so nothing happens.
I attached the pic about the settings and the script. The script works however, I run in script runner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Create a customfield (Multiselect list) then add the below script as a serverside script to it using behaviours plugin. I have not tested it .
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField import com.atlassian.jira.ComponentManager FormField projectsField = getFieldById(fieldChanged) Map fieldOptions = [:] def projectManager = ComponentManager.getInstance().getProjectManager() for(p in projectManager.projects) { fieldOptions.put(p.name,p.name); } projectsField.setFieldOptions (fieldOptions)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All, Hi Mizan,
I just upgraded my Jira to version 5 and I implemented the version 2.0.6 of groovyrunner.
Can we turn back to the solution of Script Fields?
Thanks,
Rumi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup , were you able to see scripted field in the list of Customfields ? add a scripted field and try the script which i provided earlier in some other question .
first try a basic example and see whether the field can be a multi select .
OR the above example of behaviours is also a simple option
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I tested it but the multi-select field is empty
Create a customfield (Multiselect list) then add the below script as a serverside script to it using behaviours plugin. I have not tested it .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField import com.atlassian.jira.ComponentManager FormField projectsField = getFieldById(fieldChanged) Map fieldOptions = [:] def projectManager = ComponentManager.getInstance().getProjectManager() for(p in projectManager.projects) { fieldOptions.put(p.name,p.name); } projectsField.setFieldOptions (fieldOptions) |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try the below code and check whether you see any options , also enable logging and add some logging to the script. you can enable logging clicking on the enable logging link .
import com.onresolve.jira.groovy.user.FieldBehaviours import com.onresolve.jira.groovy.user.FormField import com.atlassian.jira.ComponentManager FormField projectsField = getFieldById(fieldChanged) Map fieldOptions = [:] fieldOptions.put("Proj1","Proj1"); fieldOptions.put("Proj2","Proj2"); fieldOptions.put("Proj3","Proj3"); projectsField.setFieldOptions (fieldOptions)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
where can I put the code?
I insterted in Behaviour and I got this message:
Compilation failure: startup failed: Script1.groovy: 14: unexpected token: } @ line 14, column 36. fieldOptions.put("Proj3","Proj3"); } ^ 1 error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the exact script provided above . I think there is a extra '}' which you will have to remove.
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.