Available: setField() v1.127.0
The setField()
function is available from
v1.127.0
Takes two expressions —
target
and
value
— and sets the field
named by the result of the
target
expression to the result
of the value
expression.
Can be used to manipulate fields whose names are not statically
known, but computed at runtime.
Click + next to an example below to get the full details.
Set the Value of a Field +
i t e m : = 4
| setField (target ="foo" , value =i t e m + 10 )
Set the value of a target field as the result of an expression.
This is equivalent to:
i t e m : = 4
| f o o : = i t e m + 10
Starting with the source repository events.
In a test
event the field
item is set to
4
.
| setField (target ="foo" , value =i t e m + 10 )
Sets the value of the target field
foo as the result of the
expression value of item +
10
.
Event Result set.
Set Values for Multiple Fields +
i t e m : = 4
| b a r : = "baz"
| setField (target =b a r , value =i t e m + 10 )
| setField (target ="foo" , value =i t e m + 20 )
| setField (target ="baaz" , value =if (i t e m = = 4 , then ="OK" , else ="not OK" ) )
Set the value of more fields as the result of several expressions.
Starting with the source repository events.
In a test
event where field
item is set to
4
:
Points field bar to
field "baz" :
| setField (target =b a r , value =i t e m + 10 )
Takes field bar as the
target, gets the field pointed to by
bar
(baz ) and sets its value
as the result of the expression
value of item + 10
.
| setField (target ="foo" , value =i t e m + 20 )
Takes field foo as the
target, sets its value as the result of the expression "value of
item + 20":
| setField (target ="baaz" , value =if (i t e m = = 4 , then ="OK" , else ="not OK" ) )
Adds an if()
function whose condition will
set the value of the new target field
baaz : for example, if
item is equal to
4
, then the value of field
baaz is
OK
, otherwise
not OK
.
Event Result set.
We look at different target fields to set their values as the
result of a given expression. Functions can be added as part of
the expression in the
value
parameter,
to determine the value of another target expression.