How to add an attachment to "Generate Inbound Email" step in ATF?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi Everyone,
I have a question regarding ATF (Automated Test Framework).
I’m trying to test an inbound email flow where a request is created based on an Excel attachment sent via email. While using the “Generate Inbound Email” test step, I don’t see any option to include attachments.
Is there a way to add attachments within this step, or any recommended approach to test such attachment-based email processing using ATF?
I’ve attached a screenshot of the step for reference.
Thank you!
- Labels:
-
ATF
-
Automation
-
Email Inbound
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Here are the recommended approaches to test attachment-based inbound email processing in ATF:
Approach 1 — Custom ATF Step with GlideEmailInbound API
This is the most reliable method. You create a custom ATF test step that programmatically constructs the inbound email with an attachment using the GlideEmailInbound API. In your custom step's server-side script, you can call email.addAttachment() to attach a file (e.g., from sys_attachment or a base64-encoded payload). The general flow would be: create the GlideEmailInbound object, set your headers/body, add the attachment, and then invoke the inbound email action processing via SNC.EmailProcessor or by inserting directly into sys_email with the attachment linked.
Approach 2 — Split the Test into Two Parts
Separate attachment handling from email triggering:
- Use a "Run Server Side Script" step to create the target record (e.g., the request) and programmatically attach your Excel file to it using
GlideSysAttachment.write()— you can store a base64-encoded test file directly in the script or reference one already in the instance. - Then use subsequent steps to validate that your business logic (business rule, flow, or script action that processes the attachment) runs correctly against that record.
This doesn't test the email receipt itself end-to-end, but it does validate the attachment processing logic.
Approach 3 — Use sys_email Direct Insert
In a "Run Server Side Script" step, insert a record directly into the sys_email table with type "received," populate the relevant fields (from, to, subject, body), and then use GlideSysAttachment to attach the Excel file to that sys_email record. The inbound email actions should pick it up if they're triggered on insert or if you manually invoke processing.
Practical Tips
- For the test attachment itself, you can store a small Base64-encoded Excel file as a string constant in your script, or pre-load a test attachment into
sys_attachmentand reference it by sys_id. - If your inbound email action is the entry point, Approach 1 or 3 gives you the most realistic end-to-end coverage.
- Make sure your test cleans up after itself — delete the created records and attachments in a teardown step.
