update_options_in_list: Update values in an existing option list

Description Usage Arguments Value Examples

View source: R/option_lists.R

Description

Sends a request to the iFormBuilder API to update existing values in an option list. Option values for the specified fields will be updated to the new values supplied in the json object 'option_values'. Do not use the fields parameter. It has not been implemented yet.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
update_options_in_list(
  server_name,
  profile_id,
  optionlist_id,
  option_values,
  fields = "fields",
  limit = 1000,
  offset = 0,
  access_token = access_token
)

Arguments

server_name

String of the iFormBuilder server name

profile_id

Integer of the iFormBuilder profile ID

optionlist_id

The id number for the option list

option_values

A json object containing new option list values

fields

Placeholder for fields to update, not yet implemented

limit

The maximum number of option list items to return

offset

Skips the offset number of options before beginning to update

access_token

Access token produced by get_iform_access_token

Value

A vector of option ids for elements that were updated

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Not run: 
# Get access_token
access_token <- get_iform_access_token(
  server_name = "your_server_name",
  client_key_name = "your_client_key_name",
  client_secret_name = "your_client_secret_name")

# Get the core elements in the locations option list example.
core_elements <- get_core_option_list_elements(
  server_name = "your_server_name",
  profile_id = 123456,
  optionlist_id = your_locations_option_list_id,
  access_token = access_token)

# Inspect the first five core elements
head(core_elements, 5)

# Edit two of the core_elements we pulled above.
updated_options = core_elements[3:4,]
updated_options

# Edit. Assume RMs were incorrect.
updated_options$label[1] = "RM 0.20"
updated_options$label[2] = "RM 1.80"

# Convert location list dataframe to json
updated_options_json <- jsonlite::toJSON(updated_options, auto_unbox = TRUE)

# Send request
updated_ids <- update_options_in_list(
  server_name = "wdfw",
  profile_id = 417763,
  optionlist_id = your_locations_option_list_id,
  option_values = updated_options_json,
  access_token = access_token)

# Inspect the updated option list item ids.
updated_ids

## End(Not run)

arestrom/iformr documentation built on Nov. 25, 2021, 11:21 p.m.