Updates a specific row or inserts a new row in the reference table with specific field values.
Parameters
Parameter | Type | Description |
---|---|---|
search-field (required) | map | A field that identifies a row in the reference table, represented as a map object where the column name is the key and the field value is the value. |
new-row (required) | map | A field or fields with the new values for the specified row, represented as a map object where the column names are the keys and the field values are the values. |
Remarks
The names and type of the fields that you are inserting must match the target reference table declaration file.
The new-row parameter does not need to have a value for each of the fields in the row. Fields
with unsupplied value parameters will either not be updated if they existed in the reference
table, or, if the row is inserted as a new row, missing fields will have null
assigned
as their value. The method will throw a runtime error if null
is
assigned to a field which is marked NotNull="true"
in its declaration file,
so best practice is to always supply an explicit value for NotNull="true"
reference table columns when inserting one or more rows into them.
The method throws a More than one row found to update... error at runtime if there are more than one rows that match the search-field parameter in the reference table.
Sample
Download the declaration file for the sample reference table here.
Figure 414. The reference table used in the sample below
"Tinker was added, and all Fjord's fields were updated:", [ {name: "Fjord", age: 6, color: "ginger", weight: 10, sex: "male"}, ... {name: "Tinker", age: 1, color: "white", weight: 2, sex: "male"} ]
Figure 415. The trace message output of the script above