It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA Scriptrunner - possible to retrieve an object by ID instead of key?

Carsten Kiess Apr 23, 2019

I have some IDs (6 digit integer) and would like to understand which object they represent.

I am looking for something like:

  • anyMethodToFindObjectByID("123456")
    • which would return me e.g. an issue object
      • for which in turn I can retrieve the key e.g. "PRO-987".

Is there any such method? Or any alternative? Or are these IDs not accessible through the API? I can get the ID for a known object but apparently I can not select such an object initially by using the ID.

 

Thanks in advance! Carsten

2 answers

1 accepted

0 votes
Answer accepted
Payne Seal Community Leader Apr 23, 2019

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager

IssueManager issueManager = ComponentAccessor.getIssueManager()
Issue issue = issueManager.getIssueObject(160778)

return issue.key

Carsten Kiess Apr 24, 2019

Thanks Payne! This pointed me into the right direction. Cheers, Carsten

0 votes
Peter-Dave Sheehan Apr 23, 2019

I don't know of a way to do that.
Plus different object may end up with the same id. 
You really need to understand the context first.

One could create a script that takes an id, then iterate through all the common object types and try to obtain each object type from the given id and return all the type/class of all objects that were found matching that ID.  But that likely doesn't exist.

You might have more luck asking the community where your specific id came from by explaining where/how you got it.

Carsten Kiess Apr 24, 2019

Hi Peter, thanks, that's along the line I was thinking about - taking the ID and run it against the most common types as a tool to analyse issues. Will dig deeper into it. Cheers Carsten

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

791 views 0 12
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you