Hello, I am trying to implement a queue to sort workload priority on my JIRA instance, when a item is inserted into the queue I want to update all items with a higher number from a custom field, but I am unable to use the setCustomField() method in my IssueManager class. Is there another way to update custom fields from the scripting environment?
Here is my code:
The setCustomFieldValue() method is in the MutableIssue class, not the IssueManager class. You should be able to add the following code at various points in your script:
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
MutableIssue mutIssue
Then, inside your issues.each section add the following when you want to update
mutIssue = relatedIssue as MutableIssue
mutIssue.setCustomFieldValue(queuePriorityField, newPriorityValue)
issueManager.updateIssue(user, mutIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
//the below section will re-index the issue after the update, as that doesn't happen automatically
The approach you are using isn't recommended.
Instead of using:-
//relatedIssue.update {
// "fields": {
// "customfield_16800" : newPriorityValue
// }
//}
issues.each { relatedIssue ->
...
...
...
relatedIssue.update {
setCustomFieldValue(16800, newPriorityValue.toString()) //customfield_16800
}
}.reindex()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram, I am getting an error when trying to add the .reindex() to the end of the loop, is that a method from HAPI?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Additionally my JQL query isn't returning anything. I'm attempting to return all items that contain the customfield_16800, but am currently getting nothing. Is this the correct method to be using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a generic function that I include in all of my Scriptrunner scripts to get a list of issues from a JQL query. I pass in the authenticated user and sometimes another variable (as in the case below).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.