Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 {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:

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
TAGS
Community showcase
Published in Jira Service Management

Announcing Mindville Insight is now part of Jira Service Management!

Hello Community! We’re excited to announce that Mindville Insight’s asset and configuration management capabilities will now be integrated into Jira Service Management Premium and Enterprise plan...

736 views 12 15
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