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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published Apr 19, 2018 in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

366 views 0 6
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