How to compare two multi-pick user lists and fast-track when they are the same

Ashley Honeycutt
Contributor
December 28, 2022

I am building a change approval workflow that requires a variable number of approvers on any given issue. The user will manually enter the required approvers and an "Approve" transition is available only to users listed in that field. Once each approver has provided their approval, they are added to an "Approved By" list.

Using Scriptrunner, I want to compare the values of two custom fields that have multiple users listed, then fast track the issue through a certain transition when the values of the fields are the same.

I tried creating a fast-tracking listener with the following condition. It's not showing any errors or failures, however it's also not fast tracking to the next status.

cfValues["Approvers"] == cfValues["Approved By"]

1 answer

1 vote
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 29, 2022

Hi @Ashley Honeycutt 

Try treating your values as lists explicitly and using the groovy .equals function to compare the lists.

 

def cField1 = customFieldManager.getCustomFieldObjectByName("Approvers")

def list1 = issue.getCustomFieldValue(cField1) ?: []

def cField2 = customFieldManager.getCustomFieldObjectByName("Approved By")

def list2 = issue.getCustomFieldValue(cField2) ?: []

list1.equals(list2)

Also try

cfValues["Approvers"].values().equals(cfValues["Approved By"].values()) 

I'm less sure of this option without testing it on a server.

Suggest an answer

Log in or Sign up to answer