[Experimental]

This function will allow you to update attachments (and other blob data, such as Documents) by providing the Id of the attachment record and the file paths (absolute or relative) to media that you would like to upload to Salesforce along with other supported metadata for this operation (Name, Body, IsPrivate, and OwnerId).

sf_update_attachment(
  attachment_input_data,
  object_name = c("Attachment"),
  api_type = c("SOAP", "REST", "Bulk 1.0", "Bulk 2.0"),
  control = list(...),
  ...,
  verbose = FALSE
)

Arguments

attachment_input_data

named vector, matrix, data.frame, or tbl_df; data can be coerced into a data.frame. The input must contain a column entitled 'Body' with an absolute or relative file path (unless creating a Document using a Url) along with other required fields depending on the object.If performing an update operation, then one column or field of the input must be the Id of the record to modify.

object_name

character; the name of the Salesforce object that the function is operating against (e.g. "Account", "Contact", "CustomObject__c").

api_type

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

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 for sf_control.

...

arguments passed to sf_control or further downstream to sf_bulk_operation

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

tbl_df with details of the created records

Note

The length of any file name can’t exceed 512 bytes (per Bulk 1.0 API). The SOAP API create call restricts these files to a maximum size of 25 MB. For a file attached to a Solution, the limit is 1.5 MB. The maximum email attachment size is 3 MB. You can only create or update documents to a maximum size of 5 MB. The REST API allows you to insert or update blob data limited to 50 MB of text data or 37.5 MB of base64–encoded data.

Examples

if (FALSE) {
# upload a PDF to a particular record as an Attachment
file_path <- system.file("extdata",
                         "data-wrangling-cheatsheet.pdf",
                         package = "salesforcer")
parent_record_id <- "0036A000002C6MmQAK" # replace with your own ParentId!
attachment_details <- tibble(Body = file_path, ParentId = parent_record_id)
create_result <- sf_create_attachment(attachment_details)

# download, zip, and re-upload the PDF
pdf_path <- sf_download_attachment(sf_id = create_result$id[1])
zipped_path <- paste0(pdf_path, ".zip")
zip(zipped_path, pdf_path)
attachment_details <- tibble(Id = create_result$id, Body = zipped_path)
update_result <- sf_update_attachment(attachment_details)
}