Groovy Script For Condition

Condition-groovy script : That is, you can add a condition of a custom groovy script to the workflow, and use the groovy script in the groovy editor to implement your custom requirements.

How to add groovy script ?

(1) Click Add Condition

 


(2) Select the custom groovy script and click Add


(3) Enter name and script to run


(4) Click Add and publish the workflow


(5)When performing this transition on the issue page, the transition action is not displayed


Code examples

① Users in custom fields can be converted

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser /** * condition * Users in custom fields can be converted */ def customField = new ArrayList<>(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Approval user")); if (Objects.nonNull(customField) && customField.size() > 0){ def users = issue.getCustomFieldValue(customField.get(0)) as List<ApplicationUser>; def currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser; if (users.contains(currentUser)){ return true; } } return false;