I have an approval-style workflow post-function that appends the current user to a multi-user picker custom field. So far I've used the non-groovy "Update Issue Custom Field" post-function to append "%%CURRENT_USER%%", which doesn't behave reliably for all types of usernames. Since that method has no flexibility, I'd like to switch over to a groovy script.
The behavior ultimately relies on comparing two multi-user picker fields, "Required Approvers" and "Approved by". An "Approve" transition has been set up expecting two conditions and two post-functions:
- Condition - the current user is listed in "Required Approvers".
- Condition - the current user is not listed in "Approved by".
- Post-function - append the current user to "Approved by".
Post-function - ScriptRunner fast-track transition to the next phase of the workflow if the following condition is met:
cfValues['Approved by'] as Set == cfValues['Required Approvers'] as Set
The comparison in (4) breaks down because certain usernames (mixed case) aren't stored by "Update Issue Custom Field" (3) the same way they're stored when manually entered into the "Required Approvers" field.
In trying to re-do (3) with ScriptRunner, I'm struggling to find any up-to-date examples of appending currentUser to this type of field. The closest I've found has ultimately boiled down to using an operation like this:
Approvers.updateValue(null, issue, new ModifiedValue("", user), changeHolder);(based on code found here)
However, the ModifiedValue() part doesn't seem to be valid code anymore in the latest versions of JIRA+SR. Or at least, every example of it that I've been able to find throughout the community now returns errors.
Is there a newer, more recommended way to do this?
Thanks in advance for any help!