add_options_to_list: Add option values to new option list

Description Usage Arguments Value Examples

View source: R/option_lists.R

Description

Sends a request to the iFormBuilder API to append a list of options in json format to an existing option list. Please make sure that all option list key_values are unique, otherwise new options will not be posted.

Usage

1
2
3
4
5
6
7
add_options_to_list(
  server_name,
  profile_id,
  optionlist_id,
  option_values,
  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 list of option values in json format

access_token

Access token produced by get_iform_access_token

Value

A vector of option list element ids, one for each option in the list

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
# The locations dataset is an example of a segmented option list
head(locations, 5)

# Convert locations dataframe to json
location_json <- jsonlite::toJSON(locations, auto_unbox = TRUE)

## 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")

# Create a new empty option list
new_option_list_id <- create_new_option_list(
  server_name = "your_server_name",
  profile_id = 123456,
  option_list_name = "SGS-StreamLocations",
  access_token = access_token)

# Inspect new option list id
new_option_list_id

# Add option elements from locations dataset to the new option list
option_ids <- add_options_to_list(
  server_name = "your_server_name",
  profile_id = 123456,
  optionlist_id = new_option_list_id,
  option_values = location_json
  access_token = access_token)

# Inspect the first five new option list element ids.
head(option_ids, 5)

## End(Not run)

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