Documentation

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

NameTypeDescription
instanceUrlStringThe base URL of the Salesforce instance
accessTokenStringThe OAuth2 access token for authenticating API requests
filenameStringThe name of the file to be uploaded
caseIdStringThe Salesforce Case ID to which the comment and attachment will be added
commentStringThe comment to be added to the Salesforce case along with the attachment
base64StringThe base64-encoded content of the file to be uploaded - use 'None' if using fileURL field
fileURLOptional StringURL of the file - replaces base64 if used
dg_flow_module_loginObjectOptional object containing module-specific login details for API requests

Action Outputs

NameTypeDescription
successBooleanWhether or not the entire process was successful
contentVersionIdStringThe ID of the uploaded content version (if successfully uploaded)
reasonStringThe reason for failure, if any (only included if success is false)
errorStringError message if an exception occurred during the process (only included if success is false)

Detailed Process Flow

  1. 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.
  2. 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 uploaded ContentVersionId.
  3. 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.

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:

  1. Upload the file to Salesforce.
  2. Retrieve the content document ID of the uploaded file.
  3. 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.