Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get projectID for versionID in scriptrunner

Chuck Vanderwist
Contributor
February 27, 2018

I have a versionID and I want to retrieve the project's ID, name, Key, Lead, Category, etc

I retrieve the projectID with a versionID via http/REST with:

rest/api/2/version/{versionId}

I can then retrieve the other project details from

rest/api/2/project/{projectId}

... How would I go about retrieving the same information from within scriptrunner script, without using http requests?

I've tried using the ComponentAccessor's versionManager like this:

import com.atlassian.jira.component.ComponentAccessor
def ProjectManager = ComponentAccessor.projectManager
def VersionManager = ComponentAccessor.versionManager

long version = 23958
def versionObject = VersionManager.getVersion(version)
log.warn(versionObject)

 

...but I can't figure out how to get the projectID from the version object in this manner. 

2 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 20, 2013

I agree with Fahd that this is a bug, but not necessarily that you should create a ticket before establishing it is a bug. In this case though I think it is, although imho com.atlassian.jira.issue.customfields.manager.OptionsManager#createOption should respect the order of creating and not insert them randomly.

I think your best bet is just to import them then sort them alphabetically, which imho is always clearer for users than a custom ordering.

Karina Lasmane
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 14, 2015

Unfortunately there are situations when sorting alphabetically doesn't fit, like weekdays, months etc. :(

0 votes
Fahd
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 20, 2013

Hi Ashok,

I would highly suggest that you raise a ticket in the plugin's issue tracker to address this issue to its developer - https://jamieechlin.atlassian.net

I believed this is something that need to be fixed within the plugin's codes itself.

Regards,

Fahd

Sumit Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
January 28, 2014

Hi Ashok,

Can you provide me the code for

Bulk Import Custom Field Values function.

thanks in advance.

Regards,

Sumit

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events