Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up a Multi User Approval

Izzy Clatworthy June 15, 2023

Hello, my colleague and I are trying to set up a multi user approval to give their nod before an issue can proceed through the workflow. We have seen a couple different ways of doing this but are struggling to make any work.

We have the scriptrunner extension and are on a company managed project. 

We need have one person for each department to give their approval, ie. finance, after sales, engineering etc.

Ideally we would want this to use a field with a checkbox next to each name.

Please Help :) We're going round in circles

3 answers

1 vote
Olha Yevdokymova_SaaSJet
Atlassian Partner
August 3, 2023

Hello, @Izzy Clatworthy !
I noticed that you are currently using Scriptrunner, but I wanted to introduce you to an alternative developed by my team - Business Process Manager. This add-on offers a no-code solution for creating multi-step approval workflows and setting workflow transitions with action items. With BPM, you can save and reuse various workflow templates, leveraging dependencies and scheduling for added efficiency.Screenshot 2023-08-03 160751.png
If this sounds interesting to you, please let me know. Thank you for your attention!

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 20, 2023

A set of tickboxes is going to be really hard to work with, and you would need to set it up such that every approver was an option.

Assuming you are doing the approval by having a workflow action for "approve", then I would use either a multi-user-select list, or a set of single-user-select-lists, one for each department.

Then you can use a script like https://library.adaptavist.com/entity/calculate-custom-field-on-issue-update?tab=cloud to update it with the name(s) of the approver.

Izzy Clatworthy June 20, 2023

Thank you I'll give this a go :)

0 votes
Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 15, 2023

Hi @Izzy Clatworthy ,

Your solution should be something like : 

  • Create a Checkbox Field:

Go to Jira Administration and navigate to the "Issues" section.
Under "Custom Fields," create a new Checkbox field, such as "Department Approval."
Configure the field to have checkboxes corresponding to each department involved in the approval process (e.g., Finance, After Sales, Engineering).
Define Workflow Transitions:

  • In your Jira workflow, identify the transition(s) where the multi-user approval should occur (e.g., "Submit for Approval").
  • Edit the workflow and add a new "Script Post Function" using Scriptrunner to the desired transition(s).
    In the Script Post Function, write a script that checks the value of the "Department Approval" field for each required department. If any department checkbox is not selected, prevent the transition and display an error message to the user.
    Example:

import com.atlassian.jira.component.ComponentAccessor

// Define the required departments
def requiredDepartments = ["Finance", "After Sales", "Engineering"]

// Get the issue and custom field manager
def issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// Get the Department Approval field
def departmentApprovalField = customFieldManager.getCustomFieldObjectByName("Department Approval")

// Check if all required departments have approved
for (String department : requiredDepartments) {
def departmentValue = issue.getCustomFieldValue(departmentApprovalField)?.toString()
if (!departmentValue?.contains(department)) {
return "Error: $department approval is required."
}
}

This script assumes that the checkbox field for department approval is named "Department Approval." Modify it accordingly if you have a different field name.

  • Apply the Script:
  • Save the script and apply the Script Post Function to the desired transition(s) in your workflow.
    Publish the workflow changes.
Izzy Clatworthy June 15, 2023

Thank you very much for getting back so quickly @Frederik Vantroys 

Is there anyway for locking that to specific users?

Like Frederik Vantroys likes this
Frederik Vantroys
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 15, 2023

You can play with the script.

Maybe something like : 

import com.atlassian.jira.component.ComponentAccessor

// Define the specific users from each department
def financeApprover = "finance_user"
def afterSalesApprover = "aftersales_user"
def engineeringApprover = "engineering_user"

// Get the issue and custom field manager
def issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// Get the Approver field
def approverField = customFieldManager.getCustomFieldObjectByName("Approver")

// Get the value of the Approver field
def approverValue = issue.getCustomFieldValue(approverField)?.username

// Check if all specific users have given their approval
if (approverValue != financeApprover || approverValue != afterSalesApprover || approverValue != engineeringApprover) {
return "Error: Approval from all departments is required."
}

Izzy Clatworthy June 15, 2023

Thank You

Izzy Clatworthy June 16, 2023

@Frederik Vantroys I'm having issues with the code, it's throwing up errors because we use a Jira cloud than a jira Server.

It in particular doesn't like that first import line

Thank you in advance

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 20, 2023

I'm afraid that answer was written by an AI that doesn't understand Cloud and DC are different things, and has of course, completely ignored your "Cloud" tag.

Like Izzy Clatworthy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events