8/20/2015

JIRA Development: Getting Priorities by Name

If you want to set the priority of an issue in JIRA programmatically then you need the priorityID. This is how you get it when you only have the name (Major, Minor etc.).
String priorityID = null;
PriorityManager priorityManager = getPriorityManager();
List priorities = priorityManager.getPriorities();
for (Iterator iterator = priorities.iterator();iterator.hasNext();) {
  Priority priority = (Priority) iterator.next();
  String id = priority.getId();
  String name = priority.getName();
  if (name.equalsIgnoreCase(priorityName)){
    priorityID  = id;
  }
}
Once you have the prriorityID you can set it like that :
IssueInputParameters inputParameters = getIssueService().newIssueInputParameters();
inputParameters.setPriorityId(priorityID );


If you have any questions, feel free to leave a comment.