UploadAttachment
Uploads an attachment and associates it with a specific Salesforce record.
ストアドプロシージャ固有の情報
すべてのアップロードには ObjectId が必要です。単一のファイルまたは単一のフォルダのアップロード
単一の添付ファイルをアップロードするには、FullPath を指定します。EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FullPath = 'C:\\csv samples\\mycsvfile.csv'単一のフォルダ内のすべての添付ファイルをアップロードするには、FolderPath を指定します。
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', FolderPath = 'C:\\csv samples'Base64 データの場合は、Base64Data、FileName、および FileExtension を指定する必要があります。
EXEC UploadAttachment ObjectId = '0018Z00002nz4TkMAR', Base64Data = 'byBib2Jl', FileName = 'myfile.txt', FileExtension = 'txt'
複数値の入力のアップロード
一時 (#TEMP) テーブルを使用してファイルパスから複数の添付ファイルをアップロードするには:- まず、一時テーブルに値を挿入します。例えば:
INSERT INTO Attachment#TEMP (ObjectId, FullPath) VALUES ('0015e00000AABBCDE', 'C:\Documents\report.pdf') INSERT INTO Attachment#TEMP (ObjectId, FullPath) VALUES ('0015e00000FFGGHHJ', 'C:\Documents\invoice.pdf')これにより、値がメモリ内のテーブルに挿入されます。 - 次に、ストアドプロシージャを実行する際に同じテーブルを参照します。
EXEC UploadAttachment Attachments = 'Attachment#TEMP'
この方法には、ストアドプロシージャへの入力として任意のパラメータを使用せずに済むという利点があります。
次の例は、JSON 配列を使用して複数のファイルまたはフォルダをアップロードする方法を示しています。
ファイルパスまたは Base64 データを使用して複数の添付ファイルをアップロードするには:
EXEC UploadAttachment Attachments = '[
{"ObjectId": "0015e00000AABBCDE", "FullPath": "C:\\Documents\\report.pdf"},
{"ObjectId": "0015e00000FFGGHHJ", "FullPath": "C:\\Documents\\invoice.pdf"},
{"ObjectId": "0015e00000KKLLMMN", "Base64Data": "SGVsbG8gV29ybGQ=", "FileName": "myfile.txt"}
]'
異なるフォルダから複数の添付ファイルをアップロードするには:
EXEC UploadAttachment Attachments = '[
{"ObjectId": "0015e00000AABBCDE", "FolderPath": "C:\\Reports\\Q1"},
{"ObjectId": "0015e00000FFGGHHJ", "FolderPath": "C:\\Reports\\Q2"}
]'
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. |
| Attachments | String | False | 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. |
| 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. |
| 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. |