UploadAttachment
Uploads an attachment and associates it with an entity in Salesforce.
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 | Description |
ObjectId# | String | Required. The Id of the object to associate the uploaded document with. |
FullPath# | String | The full path to the document to upload. If Base64Data is not specified, this input is required. Either specify this or FullPath/FolderPath for a single object and not both. |
Base64Data# | String | A string of data that will be used as the full contents of the file. This must be base-64 encoded. Required if FullPath is not specified. |
FileName# | String | The name you would like to give the attachment. If none is specified, the file name specified in the FullPath will be used. Required if Base64Data is specified. |
FolderPath# | String | Used to batch upload every file inside a specified folder. Either specify this or FullPath for a single object and not both. |
LightningMode | String | Defaults to false. If set to 'True' the file will be uploaded as 'Salesforce Files'. The 'FullPath' must be specified if this is set to true. |
AttachmentTempTable | String | Used to batch upload multiple Attachment objects. Set this to a temporary table, whose rows contain upload inputs like in the example below. |
Result Set Columns
Name | Type | Description |
Id | String | The Id of the uploaded attachment. |