Arguments
- input_data
named vector
,matrix
,data.frame
, ortbl_df
; data can be coerced into adata.frame
. If performing anupdate
,upsert
, ordelete
operation, then one column or field must be theId
of the record to modify or delete.- object_name
character
; the name of the Salesforce object that the function is operating against (e.g. "Account", "Contact", "CustomObject__c").- external_id_fieldname
character
; string identifying a custom field on the object that has been set as an "External ID" field. This field is used to reference objects during upserts to determine if the record already exists in Salesforce or not.- api_type
character
; one of"REST"
,"SOAP"
,"Bulk 1.0"
, or"Bulk 2.0"
indicating which API to use when making the request.- guess_types
logical
; indicating whether or not to usecol_guess()
to try and cast the data returned in the recordset. IfTRUE
thencol_guess()
is used along withanytime()
andanydate()
. IfFALSE
then all fields will be returned as character. SpecifyingFALSE
helpful when guessing the column data type will result in NA values and you would like to return the results as strings and then cast in your script according to your unique specifications.- control
list
; a list of parameters for controlling the behavior of the API call being used. For more information of what parameters are available look at the documentation forsf_control
.- ...
arguments passed to
sf_control
or further downstream tosf_bulk_operation
- all_or_none
logical
; allows a call to roll back all changes unless all records are processed successfully.- verbose
logical
; an indicator of whether to print additional detail for each API call, which is useful for debugging. More specifically, when set toTRUE
the URL, header, and body will be printed for each request, along with additional diagnostic information where available.
Examples
if (FALSE) { # \dontrun{
n <- 2
new_contacts <- tibble(FirstName = rep("Test", n),
LastName = paste0("Contact-Create-", 1:n),
My_External_Id__c=letters[1:n])
new_contacts_result <- sf_create(new_contacts, object_name="Contact")
upserted_contacts <- tibble(FirstName = rep("Test", n),
LastName = paste0("Contact-Upsert-", 1:n),
My_External_Id__c=letters[1:n])
new_record <- tibble(FirstName = "Test",
LastName = paste0("Contact-Upsert-", n+1),
My_External_Id__c=letters[n+1])
upserted_contacts <- bind_rows(upserted_contacts, new_record)
upserted_contacts_result1 <- sf_upsert(upserted_contacts,
object_name="Contact",
"My_External_Id__c")
} # }