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()
}
}