Sync Salesforce expenses to SQL Server attachments

CRMMarketingRecipe ToolsDatabase

What it does

When someone creates or updates an expense in Salesforce with a UniqueAttachID, this automation searches SQL Server for that attachment. It retrieves matching rows from the dbo.bHQAF table and stops if the attachment is not found.

Who it's for

Accounting teams who need to link Salesforce expenses to SQL Server attachment records without manual lookup.

How teams use this

Link expenses to archived attachments

When an expense is created with a UniqueAttachID, automatically find the matching attachment record in SQL Server so finance can verify the supporting document exists without searching manually.

Skip insurance expense attachments

Filter out Subcontractor GL Insurance expenses from the lookup so only standard expenses trigger the SQL Server query. This keeps the process focused on expenses that need attachment verification.

Add approval routing for missing attachments

Extend this automation to route expenses with missing attachments to a manager for review, or set a flag in Salesforce so the expense cannot be closed until the attachment is found.

Notify teams of attachment mismatches

Include a notification step that alerts the expense owner when the UniqueAttachID does not match any record in SQL Server, so they can correct the ID or upload the missing document.

How it works

  1. Monitor new or updated expenses. Detect when someone creates or updates an expense record in Salesforce that contains a UniqueAttachID value.
  2. Look up the attachment ID. Call the Lookup AttachmentID in HQAT service to search for the attachment using the UniqueAttachID from the expense record.
  3. Query the attachment table. Select rows from the dbo.bHQAF table in SQL Server where the AttachmentID matches the result from the lookup, processing records in batch mode.
  4. Stop if attachment is missing. End this automation if the attachment ID is not found or if the expense description equals Subcontractor GL Insurance.