Adds a new record


addRecord(formId, parentRecordId = NA_character_, fieldValues)


Argument Description
formId the id of the form to which the record should be added
parentRecordId the id of this record's parent record, if the form is a subform
fieldValues a named list of fields to change.

See also

Other record functions: deleteRecord , getAttachment , getRecordHistory , getRecord , recoverRecord , updateRecord


# When providing field values, you can use either a field's code, or its
# built-in cuid. In the example below, "participant_dob" is a field code,
# and "cyz123456" is the same field's built-in id.

addRecord(formId = "cyx123", fieldValues = list(participant_dob = "1980-01-01"))
addRecord(formId = "cyx123", fieldValues = list(cxyz123456 = "1980-01-01"))

# The value of the field depends on its type.
# Most fields can be specified using an R string or number, For example:
addRecord(formId = "cxy123", fieldValues = list(
   text_field = "Alice Jones",
   multi_line_text = "Line 1\nLine 2",
   date_of_birth = "1980-01-01",
   week_project_start = "2022W1",
   month = "2023-06",
   quantity_field = 42.0))

# Single- and multiple-select fields will accept either the label of the
# select item, or the item's built-in cuid. For multiple select, you can
# provide a vector of strings.
addRecord(formId = "cxy123", fieldValues = list(
   nationality = c("Palestinian", "Jordanian"),
   registered = "Yes"

# When providing a value for a reference field, you must provide
# the built-in ID of the related record. For example, if you a have
# a field that references the Afghanistan Province form
# (,
# you must provide the record id, not the name of the province.

addRecord(formId = "cxy123", fieldValues = list(
   name = "Bibi Khan",
   province = "z0000000289"))

# When providing a value for geographic point fields, provide a named list
# for the point, including the latitude, longitude, and optionally the accuracy
# in meters reported by a geolocation sensor.

addRecord(formId = "cxy123", fieldValues = list(
   name = "Water point 42",
   location = list(latitude = 52.0735343, longitude = 4.3304164, accuracy = 12)
Next item