UploadAttachment
Uploads an attachment and associates it with a specific Salesforce record.
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, use FolderPath:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FolderPath = 'C:\\csv samples'For Base64 data, you need to specify the Base64Data, Title, and FileExtension:
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', Base64Data = 'byBib2Jl', Title = 't', FileExtension = 'txt'
Uploading multi-valued inputs
There are various ways to upload multiple files or folders. One way is to use a temporary table, #TEMP:- First insert values into temporary tables. For example:
INSERT INTO Attachment#TEMP (ObjectId, FolderPath) VALUES ( '0018Z00002nz4TkMAR', 'C:\\TestImages' ) INSERT INTO Attachment#TEMP (ObjectId, FolderPath) VALUES ('0018Z00002nz4TkMAR', 'C:\\csv samples' )This inserts the values into a table in memory. - Then reference that same table when executing the stored procedure:
EXEC UploadAttachment AttachmentTempTable = 'Attachment#TEMP'
This approach has the advantage of avoiding arbitrary parameters as inputs to the stored procedure.
Input
| Name | Type | Accepts Input Streams | Description |
| ObjectId# | String | False | The ID of the Salesforce object (such as an Account or Opportunity) to associate the uploaded file with. This field is required. |
| FullPath# | String | False | 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 | False | The full contents of the file, Base64-encoded. Required if FullPath is not provided. Useful for programmatic uploads without file system access. |
| FileName# | String | False | 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 | False | Path to a folder containing multiple files to be batch uploaded. Either specify FolderPath or FullPath, not both. |
| LightningMode | String | False | Set to 'true' to upload files as 'Salesforce Files' instead of legacy Attachments. Required when working with Salesforce Lightning. FullPath must be specified when using this mode. |
| AttachmentTempTable | String | False | A temporary table containing multiple attachment records for batch uploading. Each row must include upload details such as ObjectId and FullPath or Base64Data. |
| Content | String | True | The content of the file as an InputStream. Used when FullPath is not specified. Typically for programmatic uploads. |
Result Set Columns
| Name | Type | Description |
| Id | String | The unique ID of the newly uploaded attachment in Salesforce. |