sf_create_batches_bulk: Add Batches to a Bulk API Job

View source: R/bulk-operation.R

sf_create_batches_bulkR Documentation

Add Batches to a Bulk API Job

Description

This function takes a data frame and submits it in batches to a an already existing Bulk API Job by chunking into temp files

Usage

sf_create_batches_bulk(
  job_id,
  input_data,
  batch_size = NULL,
  api_type = c("Bulk 1.0", "Bulk 2.0"),
  verbose = FALSE
)

Arguments

job_id

character; the Salesforce Id assigned to a submitted job as returned by sf_create_job_bulk. It will start with "750".

input_data

named vector, matrix, data.frame, or tbl_df; data can be coerced into CSV file for submitting as batch request

batch_size

integer; the number of individual records to be included in a single batch uploaded to the Bulk APIs (1.0 or 2.0).

api_type

character; one of "REST", "SOAP", "Bulk 1.0", or "Bulk 2.0" indicating which API to use when making the request.

verbose

logical; an indicator of whether to print additional detail for each API call, which is useful for debugging. More specifically, when set to TRUE the URL, header, and body will be printed for each request, along with additional diagnostic information where available.

Value

a tbl_df containing details of each batch

References

https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch

Examples

## Not run: 
# NOTE THAT YOU MUST FIRST CREATE AN EXTERNAL ID FIELD CALLED My_External_Id 
# BEFORE RUNNING THIS EXAMPLE
# inserting 2 records
my_data <- tibble(Name=c('New Record 1', 'New Record 2'),
                  My_External_Id__c=c('11111','22222'))
job_info <- sf_create_job_bulk(operation='insert',
                               object='Account')
batches_ind <- sf_create_batches_bulk(job_id = job_info$id,
                                      input_data = my_data)
# upserting 3 records
my_data2 <- tibble(My_External_Id__c=c('11111','22222', '99999'), 
                  Name=c('Updated_Name1', 'Updated_Name2', 'Upserted_Record')) 
job_info <- sf_create_job_bulk(operation='upsert',
                               externalIdFieldName='My_External_Id__c',
                               object='Account')
batches_ind <- sf_create_batches_bulk(job_id = job_info$id,
                                      input_data = my_data2)
sf_get_job_bulk(job_info$id)                                     

## End(Not run)

salesforcer documentation built on March 18, 2022, 6:26 p.m.