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 vote
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

173 views 0 4
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