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?

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

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

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.

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
Community showcase
Posted in Jira

Calling all Jira Cloud users! Give us feedback on our exploration of a new navigation.

Hi everyone! My name’s Matt and I’m a product manager at Atlassian. I work in the navigation & findability space for all our Jira Cloud products. We’ve been working on trying to improve the exp...

814 views 13 12
Join discussion

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