This repo holds an example of how you can implement two custom Apex actions that let you retrieve an invoice PDF from a third party accounting system (or more generally, a file from any external system) and share it publicly.
Read this blog post [link TBD] to learn more.
This code requires the following:
- That you have a remote host that serves the invoice PDF. In my case, I wrote a basic HTTP Node server that I deployed on Heroku.
- That you deploy this code to a Salesforce Org with Agentforce.
There are two important limitations to this solution:
- This implementation cannot handle files that are larger than the Apex heap size limit.
- Storing documents on the Platform consumes data storage and you’ll need to schedule some regular cleanup so that you org does not run out of space over time.
- Configure an
Accounting_Service
External Credential that points to the server that holds the documents. - Optionnaly edit
force-app/main/default/classes/GenerateInvoice.cls
to match your service endpoint that returns the invoice. The default is/orders/ORDER_Id/invoice
whereORDER_ID
is the order ID. - Deploy the content of this repo to your org:
sf project deploy start -d force-app
You can experiment the actions with these sample prompts.
A basic example:
Get me a shareable password-protected link for the invoice of order O-12345
A more advanced example:
Draft an email to John Doe with a shareable and password-protected link to his invoice for order O-12345. Thank him for trusting ACME Corp.