a!applyComponents() Function

The a!applyComponents() Function will continue to be supported. However, a!forEach() is available in this version of Appian and provides superior capabilities over the a!applyComponents() Function

Calls a rule or function for each item in a list and supports the preservation of the local state on SAIL interfaces.

Syntax

a!applyComponents( function, array, arrayVariable )

  • function (Rule or Function Reference): Rule or expression function.
  • array (Any Type Array): Array of elements that the function iterates through.
  • arrayVariable (Any Type Array): Optional variable for preserving component or rule data.

Returns

Any Type Array

Notes

Use fn!functionName to reference an expression function and rule!ruleName to reference a rule.

The arrayVariable parameter should be passed an uninitialized local variable created via load(). a!applyComponents will store an array of state tokens in that variable. This is only required if a!applyComponents() is being invoked as part of a SAIL interface and the order of elements in array is not stable. If items in array swap positions, if an item is added to the beginning or middle, and if an item is removed from the beginning or middle, the same transformation should be applied to the arrayVariable array.

See also: load()

If array will not change, or if additions and removals only occur at the end of the array, arrayVariable is not needed.

Passing a null array returns a null list without executing the function.

To use rules or functions that take more than one argument, use the merge() function. For example, given a rule g(x, y), a!applyComponents(function: rule!g, array: merge({a, b, c}, {d, e, f})) returns {g(a, d), g(b, e), g(c, f)}.

The result of each operation is appended to each other in the same order as their corresponding item in the input list. If the result of each operation is an array, a!applyComponents() returns a two-dimensional array which can then be used for further computation. When the two-dimensional array is saved into a process variable, a node input or a custom data type, the array is flattened to a one-dimensional array. Local variables created using the with() and load() functions, however, can store the two-dimensional array without flattening it.

See also: with() and load()

If you save the nested arrays into a process variable for multiple values, the nested function is flattened. Keep in mind that casting to a flattened array only happens when saving into a process variable, node input, custom data type, or custom data type field.

See also: Arrays in Expressions

to avoid having the nested function flatten, you can use the output of the apply() function as the input for a merge() function.

see also: merge()

Examples

You can copy and paste these examples into the Expression Rule Designer to see how this works.

Given a SAIL interface rule renderEmployeeDetails and an array of employees ri!employees:

    load(
      local!stateTokens,
      a!applyComponents(
        function: rule!renderEmployeeDetails,
        array: 1 + enumerate(length(ri!employees)),
        arrayVariable: local!stateTokens
      )
    )

a!applyComponents(function: fn!isnull, array: {1,2,null,3,null,4}) returns false, false, true, false, true, false

For examples of full SAIL interfaces using a!applyComponents(), see SAIL Form Recipes.

FEEDBACK