a!update( data, index, value )
Inserts new values or replaces existing values at the specified index or field name and returns the resulting updated data.
See also:
Keyword | Type | Description |
---|---|---|
|
Any Type |
A list, map, dictionary, CDT, or record containing data to be updated. |
|
Any Type |
|
|
Any Type |
The new value to add or replace an existing value. |
Any Type
The data parameter must be a collection such as a list, map, dictionary, CDT, or record. Scalars like text, integers, and dates cannot be updated.
If the data parameter is passed a typed list, such as List of Text or List of Integer, the value parameter must be of the same type. Otherwise, a!update()
will attempt to cast the value parameter to the appropriate type for the list. If the cast is not possible, an error will occur. For example, when updating a List of Text with an Integer, the Integer will be cast to Text in the updated list.
1
2
3
4
5
a!update(
data: { 1, 2, 3 },
index: 1,
value: 5
)
Returns { 5, 2, 3 }
.
1
2
3
4
5
a!update(
data: { "ab", "cd" },
index: 2,
value: 3
)
Returns { "ab", "3" }
. The Integer 3 was cast to a Text "3" since the data parameter was a List of Text.
1
2
3
4
5
a!update(
data: { "ab", "cd" },
index: null,
value: "ef"
)
Returns { "ab", "cd" }
. A null index will result in no update to the data.
1
2
3
4
5
a!update(
data: { 1, 2, 3 },
index: 4,
value: 4
)
Returns { 1, 2, 3, 4 }
.
1
2
3
4
5
a!update(
data: { 1, 2, 3} ,
index: 6,
value: 11
)
Returns { 1, 2, 3, null, null, 11 }
. If the index is greater than the length of the list, null values are added in between the end of the original list and the new value.
1
2
3
4
5
a!update(
data: { 1, 2, 3 },
index: { 1, 4 },
value: { 11, 14 }
)
Returns { 11, 2, 3, 14 }
.
1
2
3
4
5
a!update(
data: { 1, 2, 3 },
index: { 1, 4 },
value: 11
)
Returns { 11, 2, 3, 11 }
.
1
2
3
4
5
a!update(
data: {},
index: { 2, 4 },
value: {11, 13}
)
Returns { null, 11, null, 13 }
. Since the data parameter was an empty list, updating non-consecutive indices results in null values being added in the remaining indices.
1
2
3
4
5
a!update(
data: a!map(a: 1, b: 2),
index: "a",
value: 5
)
Returns a!map(a: 5, b: 2)
.
1
2
3
4
5
a!update(
data: { a!map(x: 10, y: 20), a!map(x: 1, y: 2) },
index: "x",
value: { -10, -1 }
)
Returns { a!map(x: -10, y: 20), a!map(x: -1, y:2) }
.
1
2
3
4
5
a!update(
data: a!map(a: 1, b: 2),
index: {"a", "b"},
value: { 5, 6 }
)
Returns a!map(a: 5, b: 6)
.
1
2
3
4
5
a!update(
data: a!map(a: 1, b: 2),
index: {"a", "a"},
value: { 5, 6 }
)
Returns a!map(a: 6, b: 2)
.
1
2
3
4
5
a!update(
data: a!map(a: 1, b: 2),
index: "c",
value: 3
)
Returns a!map(a: 1, b: 2, c: 3)
.
1
2
3
4
5
a!update(
data: a!map(),
index: "a",
value: 1
)
Returns a!map(a: 1)
.
1
2
3
4
5
a!update(
data: a!map(),
index: {"a", "b"},
value: { 5, 6 }
)
Returns a!map(a: 5, b: 6)
. Since the data parameter was an empty map, the specified fields will be added to the map.
In general, the same rules that apply to maps will apply to dictionaries.
1
2
3
4
5
a!update(
data: { a: 1, b: 2 },
index: "a",
value: 5
)
Returns { a: 5, b: 2 }
.
In order to test record examples, you will need to create a record type with the same field names. Use record field references instead of strings shown in the examples below.
In this example, there is a record type called "Customer" with 3 fields on it: id, name, and age.
1
2
3
4
5
a!update(
data: recordType!Customer(id: 4, name: "Jane", age: 42),
index: recordType!Customer.fields.age,
value: 43
)
Returns recordType!Customer(id: 4, name: "Jane", age: 43)
.
In this example, there is a record type called "Customer" with 3 fields on it: id, name, and age.
1
2
3
4
5
a!update(
data: { recordType!Customer(id: 4, name: "Jane", age: 42), recordType!Customer(id: 7, name: "John", age: 35)},
index: recordType!Customer.fields.age,
value: {43, 36}
)
Returns { recordType!Customer(id: 4, name: "Jane", age: 43), recordType!Customer(id: 7, name: "John", age: 36)}
.
In this example, there is a record type called "Customer" with 3 fields on it: id, name, and age.
1
2
3
4
5
a!update(
data: recordType!Customer(id: 4, name: "Jane", age: 42),
index: {recordType!Customer.fields.name, recordType!Customer.fields.age},
value: {"Jane Doe", 43}
)
Returns recordType!Customer(id: 4, name: "Jane Doe", age: 43)
.
In this example, the record type "Customer" has a 1:1 relationship with the record type "Address".
1
2
3
4
5
6
7
a!update(
data: recordType!Customer(
Address: recordType!Address(zip: 12345)
),
index: recordType!Customer.relationships.Address.fields.zip,
value: 23456
)
Returns recordType!Customer(Address: recordType!Address(zip: 23456))
.
In this example, the record type "Customer" has a 1:1 relationship with the record type "Address".
1
2
3
4
5
a!update(
data: recordType!Customer(Address: null),
index: recordType!Customer.relationships.Address,
value: recordType!Address(zip: 12345)
)
Returns recordType!Customer(Address: recordType!Address(zip: 12345))
.
In order to test the CDT examples, you will need to create a CDT with the same field names.
In this example, there is a CDT called "Customer" with 3 fields on it: id, name, and age.
1
2
3
4
5
a!update(
data: type!Customer(id: 3, name: "John", age: 30),
index: "age",
value: 31
)
Returns type!Customer(id: 3, name: "John", age: 31)
.
In this example, the top level CDT called "mainCDT" has a nested CDT inside of it called "nestedCDT" which has one field called "field1".
1
2
3
4
5
6
7
8
9
10
11
a!update(
data: type!mainCDT(
nestedCDT: type!nestedCDT(field1: "abc")
),
index: "nestedCDT",
value: a!update(
data: type!nestedCDT(field1: "abc"),
index: "field1",
value: "New Value"
)
)
Returns type!CDT(nestedCDT: type!nestedCDT(field1: "New Value"))
. Multiple, nested a!update functions are required to update this value since the field to be updated cannot be referenced in the top level index parameter.
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | 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 | |
Process Reports | Incompatible | You cannot use this function to configure a process report. |
Process Events | Incompatible | You cannot use this function to configure a process event node, such as a start event or timer event. |
a!update() Function