Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,058
Community Members
 
Community Events
176
Community Groups

Restrict approval based on selected approver in a Software project.

Edited

I would like to know if it's possible, using ScriptRunner, to restrict who approves tickets created within a software project.
I have a custom field Approvers (Single Select).
The people who can be added as approvers are defined in the users and groups of the project,
I used validation on the workflow to make sure the Reporter and Approver are not the same person.
I now have to make sure that the approvers selected is the only person who can press the approval button and not anyone in this group.

I have behaviour scripting for the Reporter and Approver to not be the same
How do I change it to validate that the selected approver is the one that press the approval button and not anyone in the group?

// Get the current user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// Get the changed field
def approversField = getFieldByName("Approvers (Single)")
def reporterField = getFieldById("reporter")

//def userInPickerCF = it.getCustomFieldValue(approverFieldValue)

if(!(approversField.getValue()?.toString().equals("")))
{
if(approversField.value.toString() == reporterField.value.toString()
/* || currentUser.key == approversField.value.toString() */|| reporterField.value.toString() == approversField.value.toString())
{
approversField.setError("Please select a different Approver (Approver must not be the same as Reporter)")

}
else
{
approversField.clearError()
}
}

1 answer

1 accepted

0 votes
Answer accepted

You can use a Condition in your Approve transition to ensure that only the user in the Approvers custom field can see the Approve button.

I have this condition. It still allows everyone in the role of the approvers to see the ticket.
I want only the selected approver to see the approval button and not everyone in the group.

I opted to use the workflow functions to assign the ticket to the selected approver and then to have a condition that only assignee can approve the request as well as be in the group/role.
Then I added a post function to clear the assignee field.

This will also help with notification of the assigned ticket.
No need for scripting.

It's great to have the ability to use scripting to meet requirements. But it still adds some maintenance overhead. So if you can meet your requirement without scripting, that's always best.

Like Natasja Eloff likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events