Skip to contents

[Experimental]

Usage

submission_edit(
  iid,
  field,
  value,
  comment = NULL,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

field

(character) The XForms field to edit, e.g. "name" or "/data/name".

value

The new field value, coerced to a string. It must match the field type from form_schema(): integers for "int", numbers for "decimal", anything for "string".

comment

(character) A comment about the edit, posted with submission_comment_create(). Default: NULL (no comment posted).

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A list with the update result from submission_update() and, if a comment was given, the comment result from submission_comment_create().

Details

This convenience wrapper edits one field of a Submission and, optionally, leaves a comment about the edit. It downloads the current Submission XML, sets the field to the new value, rotates the deprecatedID metadata node to the current instanceID, assigns a new instanceID, uploads the result with submission_update(), and posts the comment with submission_comment_create(). The new value is checked against the field type from form_schema().

Examples

if (FALSE) { # \dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")

sl <- submission_list()
iid <- sl$instance_id[[1]]

se <- submission_edit(
  iid = iid,
  field = "name",
  value = "Jo updated",
  comment = "Fixed the name."
)

se$update$current_version$instanceId
} # }