JavaScript Filter

You can automatically assign tasks to subsets of teams with a User Task. By adding a filter to the team, you can assign the task to users who have a specific role on the team or who share some other criteria. JavaScript expressions let you customize the filter to meet your exact needs.

When creating your JavaScript filter there are few things to keep in mind:

Methods

Use the following methods to create your filter.

Parameters: Possible parameters are noted in italics. If an expression takes parameters, you can pass multiple parameters in a comma separated list and the expression will return team members who satisfy any of the parameters.

Note: When you test JavaScript that uses TaskSubmitter methods, it will assume the previous task has not run. Thus, during the test, no team members will be returned for findTaskSubmitters and all team members will be returned for excludeTaskSubmitters.

Helper methods

To use more than one of the expressions listed above in a single filter, you will need to assign each expression to a variable and then pass those variables to a helper method. Alternatively, you can directly pass the expressions as helper method parameters.

Parameters: The union and intersection helper methods can take any number of parameters. The difference method requires two parameters.

Advanced example

Using $test in the team filter

You can use the keyword “$test” in a team filter to view the attributes of the results found. Those results are displayed in a separate “$test Output” field. For example, using “$test” instead of “$result” in the first statement of the following, you can see each resulting user as an object with a set of attributes:

$test=team.excludeRoles('roledoesntexist')
$result=team.excludeRoles('roledoesntexist')

For example, if “=team.excludeRoles('roledoesntexist')” returns two team members, you can prepend “$test” to see the attributes of each user, like the user’s roles and user name. The following returns the results along with a second “$test Output” field for viewing each object and the attributes: