Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Fetch a subset of values of a multi-valued field based on a condition
Abstract
This code snippet filters values from a collection of objects based on a condition
Logic
Iterate over the collection of objects and filter values that meet the condition
Snippet
//Define an array to find and store the filtered values def newValues = issue.get("<Multi-valued field name>").findAll{ //Write the condition <Condition> } return newValues
Placeholders
Placeholder | Description | Example |
---|---|---|
> | Name of the multi valued field | watches |
> | Condition to meet for the value to be filtered | it.getName() != issue.get("reporter").getName() |
Examples
The output of this snippet is a subset of the existing values of a multi-valued field which you could use in a Groovy expression, to
Send an email to all the customers watching the ticket using the Email issue post-function. For this, you need to add this script in the "Users from script" field in the post-function configuration
return issue.get("watches").findAll{ it.isInProjectRole("Service Desk Customers",issue.get("project") ) }
References
- Variables used in a Groovy expression
- Issue interface
- Accessing the fields of an issue
- Groovy Documentation
Related articles