Forums

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

Adding the user who performed the action in the task to the custom field with users.

Alibek Malikov February 28, 2019 edited

I need help!
I need a script that I could add to the post-funcsion
I need the script to work out when the user clicks on the "approve" button and that he would be automatically added to the list of "approved users".

And if the user clicks on the "do not approve" button, then he should also automatically be added to the list with users who "do not approveed users" the request.

1 answer

0 votes
Sreenivasaraju P
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.
February 28, 2019
Alibek Malikov February 28, 2019
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser

CustomField multiUser = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("fieldName")
List<ApplicationUser> users = issue.getCustomFieldValue(multiUser)
if(users == null)
    users = new ArrayList<>();

users.add(ComponentAccessor.getUserManager().getUserByName("username"))

issue.setCustomFieldValue(multiUser, users);


!!!I use this script in the post-function but it gives an error!!!


 
The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script23.groovy: 9: unexpected token: ; @ line 9, column 28. users = new ArrayListlt;&gt;(); ^ 1 error </pre>.

Alibek Malikov July 8, 2019

Thanks a lot for your help)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events