Script which results the list of the names of the current projects in Jira

Hi All,

I would like to use this script in a scripted custom field. I would like to get a list of the names (notproject keys!) of the current project in our Jira instance.

Another request would be a bit difficult(?): we also need the list of names of the current space names (not personal space!) of our Confluence.

Can you please suggest?

Thanks in advance,

Rumi

2 answers

1 accepted

0 votes
Accepted answer
Mizan Community Champion Jun 19, 2012

Try the below script (taken from the script runner docs) , but i am not sure how it will display the values . were you able to create a simple multiselect field which displays few options in the list ?

import com.atlassian.jira.ComponentManager
 
def projectManager = ComponentManager.getInstance().getProjectManager()
def result="";
for(p in projectManager.projects) {
    result += "$p.name";
}
return result;


Thank you Mizan, it works!

Mizan Community Champion Jun 24, 2012

Great :) ...

I would use the REST API to get all projects accessible for the currently logged in user. For more info, please see the following documentation: http://docs.atlassian.com/jira/REST/latest/#id160865

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

309 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you