Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Can I use ScriptRunner to find out who approved an issue

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.

1 answer

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 { == "Approvers"}

//get the second level approver user
ApplicationUser botUser = ComponentAccessor.getUserManager().getUserByName("admin")

//add the user to the approver list

//set the approver list to the Approvers custom field
issue.setCustomFieldValue(approversCF, approversList)

For more clear to where set the script:

Screenshot 2021-04-07 at 6.12.52 PM.png

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

JSM Jira Automation: How to Send SLA Breached Notifications

Hi Everyone, In   this tutorial,  we will show you how you can monitor an SLA, and send notifications before or after the SLA has been breached.   SLA Threshold Trigger The SLA t...

626 views 5 12
Read article

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