Skip to content

Commit

Permalink
AI-3942: add record id arg to addRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Whitehouse committed Oct 24, 2023
1 parent ecf53a3 commit 0cad17a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/records.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ recordExists <- function(formId, recordId) {
#' @param formId the id of the form to which the record should be added
#' @param parentRecordId the id of this record's parent record, if the form is a subform
#' @param fieldValues a named list of fields to change.
#' @param recordId the id of the new record when a custom id is desired. The given id must be in cuid-compatible format.
#' @export
#' @family record functions
#' @examples
Expand Down Expand Up @@ -73,12 +74,16 @@ recordExists <- function(formId, recordId) {
#' ))
#'
#' }
addRecord <- function(formId, parentRecordId = NA_character_, fieldValues) {
addRecord <- function(formId, parentRecordId = NA_character_, fieldValues, recordId = NA_character_) {
stopifnot(is.character(formId))
stopifnot(is.character(parentRecordId))
stopifnot(is.list(fieldValues))

recordId <- cuid()
stopifnot(is.character(recordId))

if (identical(recordId, NA_character_)) {
# generate a record id if not provided
recordId <- cuid()
}
changes <- list(
list(
formId = formId,
Expand Down

0 comments on commit 0cad17a

Please sign in to comment.