bind( get, set )
Use in conjunction with the load function to bind getter and setter functions to a variable. When the variable is read, the getter function or rule will be called. When the variable is saved into, the writer returned by the setter function or rule will be called. The setter function must return a writer.
The bind()
function lets you bind a getter and setter rule or function to a variable such that when that variable is read, the getter method is called and when it is saved into, the writer returned by the setter method is called.
See also: Writer Functions
Keyword | Type | Description |
---|---|---|
|
Any Type |
A rule or function that returns any type. The rule or function given as the |
|
Writer |
A rule or function that returns a writer. The writer will execute when the bound variable is written to in a |
Any Type
The bind()
function can only be used when defining variables using the load()
function in interfaces. Local variables created using a!localVariables()
do not support the bind()
function.
The rule or function given as the get
parameter will not be evaluated until the bound variable is evaluated in the expression. If the bound variable is never referenced in the expression, but only used in a saveInto
, the get
will be called prior to saving into the variable. If the bound variable is referenced many times in the expression and the get
function is always passed the same parameters, it will only evaluate the get
on the first reference and retrieve the result from cache for subsequent references.
Bound variables cannot be used as the get
parameter of a subsequent bind()
function.
The rule or function given as the set
parameter must be a partial function with underscores indicating arguments that will be supplied when saving into the variable. The first blank argument will be filled with the value being saved into the variable. The second blank argument will be filled with one or more indices that are being saved into.
When saving into the variable, the rule or function given as the set parameter must return a writer
. If a rule is given as the set
parameter, that rule must not use the load()
function in its definition.
During the save evaluation when a saveInto
is triggered in the interface, the writer
associated with the bound variable being saved into will execute its write method.
Any errors that occur during evaluation of the get
will be handled as an expression evaluation error and cause the remainder of the expression to fail evaluation. Any errors that occur during evaluation of the set
will occur after any non-bind saves are evaluated and will be displayed as an error to the user, but will not cause the evaluation of the expression to fail.
local!variable.field1
, the index argument supplied will be field1
local!variable[18]
, the index argument supplied will be 18
local!employee.address.city
, the index argument supplied will be the array of indices {address, city}
See the Edit Data in an External System recipe for an example of how to use the bind()
function.
Feature | Compatibility | Note |
---|---|---|
Portals | Partially compatible | Can be used with Appian Portals if it is connected using an integration and web API. |
Offline Mobile | Partially compatible | Can be used with offline mobile if it is loaded at the top of the form. |
Sync-Time Custom Record Fields | Incompatible | |
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 | Incompatible | Cannot be used to configure a process event node, such as a start event or timer event. |
bind() Function