Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

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

PlaceholderDescriptionExample
<Multi-valued field name>Name of the multi valued fieldwatches
<Condition>Condition to meet for the value to be filteredit.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

  • Set a multi-valued field to a subset of the existing values in one of the Set field value post-functions and the Create issue post-function under Set fields of new issue section. Example: Set a Multi-user picker type field to the users in the Watchers field excluding the Reporter of the issue:

    def newValues = issue.get("watches").findAll{
      it.getName() != issue.get("reporter").getName()
    }
    return newValues
  • Send an email to all the users of the Request Participants when a meeting schedule has been changed, except to the current user in the Email issue post-function

    def newValues = issue.get("Request Participants").findAll{
      it.getName() != currentUser.getName()
    }
    return newValues

References

  • No labels