Free cookie consent management tool by TermsFeed

all() Function

On This Page

Calls a rule or function that returns either true or false for each item in list, asks the question, "Do all items in this list yield true for this rule/function?", and returns true if all items in list evaluates to true.

Parameters

all( predicate, list, context )

Keyword Type Description

predicate

Function, Rule, or Data Type Constructor

Expression that returns a Boolean (true or false).

list

Any Type Array

List of elements that the predicate iterates through.

context

Any Type Array

Variable number of parameters passed directly into each predicate evaluation.

Returns

Boolean

Using the function

The following sections cover important details about the all() function.

List evaluation results

The all() function checks whether every item in the list parameter satisfies the condition defined by the predicate parameter, and returns a single Boolean result.

The all() function returns true only if every item in the list satisfies the condition. For example, the following expression returns true because user1, user2, and user3 are all members of the group referenced by cons!csaBuilding1.

1
2
3
4
5
all(
  a!isUserMemberOfGroup,
  {"user1", "user2", "user3"},
  cons!csaBuilding1
)

The all() function returns false as soon as an item in the list does not satisfy the condition. For example, the following expression returns false because user6 is not a member of the group referenced by cons!csaBuilding1, even though user1 and user3 are members.

1
2
3
4
5
all(
  a!isUserMemberOfGroup,
  {"user1", "user6", "user3"},
  cons!csaBuilding1
)

If the list parameter is empty or null, the all() function returns true.

Using the predicate parameter

In the predicate parameter of all(), enter fn!functionName or a!functionName to reference an expression function, or rule!ruleName to reference a rule.

Using rules or functions with multiple arguments

To use rules or functions that take more than two arguments, use the merge() function. For example, given a rule g(x, y, z), reduce(rule!g, i, merge({a, b, c}, {d, e, f})) returns g(g(g(i, a, d), b, e), c, f).

Using the context parameter

The context parameter lets you pass fixed parameters that stay the same for each list item.

When the predicate parameter has more than two parameters, the context parameter provides the remaining ones. See Checking all items with context for an example.

Unsupported functions

The all() function doesn't support a!forEach() in rules that you use as the predicate.

Examples

The following examples demonstrate the all() function.

To experiment with examples, copy and paste the expression into an expression rule and click TEST RULE to see the output.

Checking all items in a list

This example checks whether every item in a list is populated, using a!isNotNullOrEmpty as the predicate.

1
2
3
4
all(
  a!isNotNullOrEmpty,
  {1, 2, null, 3, null, 4}
)

Returns false because the list contains null items.

Checking all items in an empty list

This example shows how all() behaves when the list parameter is empty.

1
2
3
4
all(
  a!isNotNullOrEmpty,
  {}
)

Returns true. An empty or null list always returns true because no items fail the predicate.

Checking all items with context

To help demonstrate how the context parameter works in looping expressions, let's look at an example.

Imagine you're building an expression that uses looping to analyze group membership in your application. You have four Group constants configured in the following ways:

Constant Group(s) referenced Group membership
cons!csaAdmins CSA Administrators user1, user3
cons!csaProfs CSA Professors user1, user2, user4, user5, user6, user7
cons!csaBuilding1 CSA Building 1 user1, user2, user3, user5, user6, user7
cons!allGroups CSA Adminstrators, CSA Professors, CSA Building 1 See above

The following expressions reference these constants to show how context works when checking items in a list.

Note:  These examples reference constants from another environment and will error if you try to use them in yours. Use them as a reference only.

Checking items with a single context value

This example uses the context parameter to pass a group into every evaluation of the predicate.

1
2
3
4
5
all(
  a!isUserMemberOfGroup,
  {"user1", "user2", "user3"},
  cons!csaBuilding1
)

Returns true. Since user1, user2, and user3 are all members of the group referenced by cons!csaBuilding1, the all() function returns true.

Checking items with multiple context values

This example checks whether every user in a list belongs to all groups in a set. It passes two context values into a!isUserMemberOfGroup, which takes more than two parameters.

1
2
3
4
5
all(
  a!isUserMemberOfGroup,
  {"user1", "user2", "user3"},
  {cons!allGroups, true}
)

The a!isUserMemberOfGroup function has three parameters: username, groups, and matchAllGroups. The list parameter of all() supplies the username for each evaluation, and the two values in the context parameter supply the remaining parameters: groups is cons!allGroups, and matchAllGroups is true. Because matchAllGroups is true, each user must belong to every group in cons!allGroups to satisfy the predicate.

The all() function evaluates the predicate once per user:

  • user1: Belongs to every group in cons!allGroups, so the predicate returns true.
  • user2: Does not belong to every group, so the predicate returns false.
  • user3: Does not belong to every group, so the predicate returns false.

The all() function returns true only when every item satisfies the predicate. Because user2 and user3 return false, all() returns false.

Checking items with list context values

This example uses merge() to pass list values through the context parameter, mapping each list to a predicate parameter.

1
2
3
4
5
all(
  a!isUserMemberOfGroup,
  {"user1", "user2", "user3"},
  merge({cons!csaAdmins, cons!csaProfs}, {true, true})
)

Returns false when only user1 is a member of the groups referenced in cons!csaAdmins and cons!csaProfs. The merge() function maps the list values to the correct parameters in this example.

Checking a list with a custom expression rule

This example checks whether every date in a list is later than a reference date. It uses a helper rule, rule!isDateLater(value, referenceDate), defined as:

1
ri!value > ri!referenceDate

Example filter:

1
2
3
4
5
all(
  rule!isDateLater,
  {date(1950, 2, 3), date(1950, 6, 23), date(1950, 5, 2)},
  date(1950, 4, 7)
)

Returns false.

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Compatible
Offline Interfaces Compatible
Sync-Time Custom Record Fields Compatible

Can be used to create a custom record field that only evaluates at sync time.

Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Partially compatible

If autoscale is enabled, can be used to configure a supported process event node (such as a start event or timer event).

Process Autoscaling Compatible

Can be used in autoscaled processes.

Event Consumer Filter Conditions Compatible

Can be used in filter conditions.

Event Consumer Event Handlers Compatible

Can be used in event handler expressions.

Feedback