We have a change request and I'm having some difficulties trying to make it so that we don't have one person approving the same issue twice. Our change request workflow has 2 statuses that require an approval to transition: "Waiting Approval Level 1" and "Waiting Approval Level 2". Each of the approvals has it's own group of approvers: Approvers Level 1 and Approvers Level 2. This wouldn't be a problem if we didn't have an overlap of 3 agents between the 2 groups.
What I would like to do is after the 1st approval has been done, set the user picker for the 2nd approval to be everyone in "Approvers Level 2" minus the approver from the 1st approval.
Jira has a function that will tell me who can approve the request but nothing that will tell me who approved the request. I've looked at a test issue in the API and I've seen the information I need in it, but I'm not sure how to get it in a useable form. I'm hoping that this is something ScriptRunner can do, but before I head down that rabbit hole, I'd like to know if it's even possible to use ScriptRunner to find out who approved an issue.
Hi @Kimi Nakashima ,
You can add this script in the 1st approval and set the desired user on the Approvers field to whom you want the user to approve the second level.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
List<ApplicationUser> approversList = new ArrayList<>()
//find the Approvers custom field
def approversCF = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find {it.name == "Approvers"}
//get the second level approver user
ApplicationUser botUser = ComponentAccessor.getUserManager().getUserByName("admin")
//add the user to the approver list
approversList.add(botUser)
//set the approver list to the Approvers custom field
issue.setCustomFieldValue(approversCF, approversList)
For more clear to where set the script:
It will change the approver user (to your desired users) after the 1st approval.
I hope this helps.
Do let us know if you have any question.
John Chin
How does this identify WHO approved the issue?
@Kimi Nakashima question is the same as mine, an issue has already been approved, using ScriptRunner how do we identify which user has approved the issue?
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.