Cmdlets for Salesforce

Build 25.0.9434

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:
  1. 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.

  2. 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.
Alternatively, you can specify multiple FullPaths using a #TEMP table or use multiple Base64 data entries.

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.
LightningMode String 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 A temporary table 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.

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434