UploadAttachment
Uploads an attachment and associates it with a specific Salesforce record.
Stored Procedure-Specific Information
ObjectId is required for all uploads.Uploading Single Files or Single Folders
To upload a single attachment, specify the FullPath:EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FullPath = 'C:\\csv samples\\mycsvfile.csv'To upload all attachments in a single folder, specify the FolderPath:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FolderPath = 'C:\\csv samples'For Base64 data, you must specify the Base64Data, FileName, and FileExtension:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', Base64Data = 'byBib2Jl', FileName = 'myfile.txt', FileExtension = 'txt'
Uploading Multi-Valued Inputs
To upload multiple attachments by file path using a temporary (#TEMP) table:- First insert values into #TEMP tables. For example:
INSERT INTO Attachment#TEMP (ObjectId, FullPath) VALUES ('0015e00000AABBCDE', 'C:\Documents\report.pdf') INSERT INTO Attachment#TEMP (ObjectId, FullPath) VALUES ('0015e00000FFGGHHJ', 'C:\Documents\invoice.pdf')This inserts the values into a table in memory. - Then reference that same table when executing the stored procedure:
EXEC UploadAttachment Attachments = 'Attachment#TEMP'
This approach has the advantage of avoiding arbitrary parameters as inputs to the stored procedure.
The following examples demonstrate how to upload multiple files or folders using a JSON array:
To upload multiple attachments by file path or Base64 data:
EXEC UploadAttachment Attachments = '[
{"ObjectId": "0015e00000AABBCDE", "FullPath": "C:\\Documents\\report.pdf"},
{"ObjectId": "0015e00000FFGGHHJ", "FullPath": "C:\\Documents\\invoice.pdf"},
{"ObjectId": "0015e00000KKLLMMN", "Base64Data": "SGVsbG8gV29ybGQ=", "FileName": "myfile.txt"}
]'
To upload multiple attachments from different folders:
EXEC UploadAttachment Attachments = '[
{"ObjectId": "0015e00000AABBCDE", "FolderPath": "C:\\Reports\\Q1"},
{"ObjectId": "0015e00000FFGGHHJ", "FolderPath": "C:\\Reports\\Q2"}
]'
Input
| Name | Type | Description |
| ObjectId | String | The ID of the Salesforce object (such as an Account or Opportunity) to associate the uploaded file with. This field is required. |
| FullPath | String | The full file path of the document to upload from your local system. Required if Base64Data is not provided. Only one of FullPath or FolderPath should be specified per upload. |
| Base64Data | String | The full contents of the file, Base64-encoded. Required if FullPath is not provided. Useful for programmatic uploads without file system access. |
| FileName | String | The name to assign to the uploaded attachment. Required if using Base64Data. If using FullPath, the file name will be derived automatically if this is left blank. |
| FolderPath | String | Path to a folder containing multiple files to be batch uploaded. Either specify FolderPath or FullPath, not both. |
| Attachments | String | Accepts a temporary table name or an aggregate (JSON) containing multiple attachment records for batch uploading. Each row must include upload details such as ObjectId and FullPath or Base64Data. |
Result Set Columns
| Name | Type | Description |
| Id | String | The unique ID of the newly uploaded attachment in Salesforce. |
| Success | Boolean | Indicates whether the file upload succeeded (true) or failed (false). |
| FileIdentifier | String | Identifies the file for this result row. Contains the full file path when FullPath or FolderPath was used, or the file name when Base64Data or Content stream was used. |
| Errors | String | Error messages returned by Salesforce if the upload failed, including error codes and descriptions. |