How to get a Jira priority order with the Java API?

I am trying to get information from a specific priority. I have it’s id and I am able to fetch the Priority object with the PriorityManager, but I cannot find the Order information.

I would like to create a new Priority, which I am able, but to create it at a specific location (order-wise) compared to the other priorities. I saw that there are movePriorityUp and movePriorityDown functions, but nothing to know at which position the priority currently is. Is there a way to do that?

I am working with the priority schemes available in Jira 7.6+

Note: I haven’t used the Priorities yet so I’m not familiar with the new api 100% (but your question made me have an excuse - so thank you :slight_smile: ).

But you’ll need to use or .

Poking around - the PrioritySchemeService is probably the easier one to work with… :slight_smile:

I did not see the PrioritySchemeService before, but I was using the PrioritySchemeManager to create Priority Schemes and assign them to projects. However, those manage Priority Schemes, not priorities themselves, and I don’t see a way to get the order information in those either. When I look at the Priorities list (without the schemes), they all are in a specific order. For example, if I try to compare two priorities, to know which one is more urgent, how do I know without going to the Jira UI and checking that column? Ideally, I would like to get a integer value telling me the Priority order or something like that, so that when I create a new Priority, I am able to place it exactly where I want.

Looking at the api - it looks like Jira is treating this as a custom field’s data which means that you’d call and get the priorities as a list - then you’ll need to find where the current value fits in.

I was able to get the list of priorities from a priority scheme

OptionSetManager optMgr = ComponentAccessor.getComponent(OptionSetManager.class);
OptionSet optSet = optMgr.getOptionsForConfig(scheme.getOneAndOnlyConfig());
List<String> options = new ArrayList<String>(optSet.getOptionIds());

It gives me a list of ids of the priorities in the scheme, and then I can get the each priority object with the id. However, there does not seem to be any information on the priority position compared to the others (unless the list is sorted according to that order?)