Salesforce Upload Attachment
Upload attachment and add chatter comment.
Documentation for Uploading and Commenting on an Attachment in Salesforce
Description
This action uploads an attachment to a Salesforce record, retrieves the document ID, and adds a comment to a related Salesforce case with the attached document.
Action Inputs
Name | Type | Description |
---|---|---|
instanceUrl | String | The base URL of the Salesforce instance |
accessToken | String | The OAuth2 access token for authenticating API requests |
filename | String | The name of the file to be uploaded |
caseId | String | The Salesforce Case ID to which the comment and attachment will be added |
comment | String | The comment to be added to the Salesforce case along with the attachment |
base64 | String | The base64-encoded content of the file to be uploaded - use 'None' if using fileURL field |
fileURL | Optional String | URL of the file - replaces base64 if used |
dg_flow_module_login | Object | Optional object containing module-specific login details for API requests |
Action Outputs
Name | Type | Description |
---|---|---|
success | Boolean | Whether or not the entire process was successful |
contentVersionId | String | The ID of the uploaded content version (if successfully uploaded) |
reason | String | The reason for failure, if any (only included if success is false ) |
error | String | Error message if an exception occurred during the process (only included if success is false ) |
Detailed Process Flow
-
API Call to Upload Attachment:
- URL:
/services/data/v44.0/sobjects/ContentVersion/
- Method:
POST
- Payload: Multipart form data including file metadata and content.
- Outcome: Uploads the file to Salesforce and returns a
contentVersionId
if successful.
- URL:
-
Retrieve Content Document ID:
- URL:
/services/data/v44.0/query/?q=SELECT ContentDocumentId FROM ContentVersion WHERE Id = '${contentVersionId}'
- Method:
GET
- Outcome: Retrieves the
ContentDocumentId
linked to the uploadedContentVersionId
.
- URL:
-
Add Chatter Comment with Attachment:
- URL:
/services/data/v44.0/chatter/feed-elements
- Method:
POST
- Payload: JSON payload containing the comment and the associated attachment (
ContentDocumentId
). - Outcome: Posts a comment with the attached document to the specified Salesforce case.
- URL:
Error Handling
- Upload Attachment: If the upload fails, the process stops, and the error is logged and returned.
- Retrieve Document ID: If retrieving the
ContentDocumentId
fails, the process stops, and the error is logged and returned. - Add Comment: If adding the comment fails, the process stops, and the error is logged and returned.
Example Usage
Given the necessary inputs such as instanceUrl
, accessToken
, filename
, caseId
, and base64
encoded file data, this action will:
- Upload the file to Salesforce.
- Retrieve the content document ID of the uploaded file.
- Add a Chatter comment to the specified Salesforce case with the uploaded document attached.
If any step fails, an appropriate error message will be returned along with the status of the operation.
This structure provides a clear guide for the QA team to understand the inputs, outputs, process flow, and error handling associated with this action.
Updated 2 months ago