Inbound email action for attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 06:36 AM
Hi Team,
When an external sender/vendor replies to the email sent by SNOW with attachments WITH the word #Success, the attachments SHOULD NOT be attached to the ticket in regardless of what format the attachments would be. Email content will still be attached to the ticket, and the activity will have the record of the email
i mean if there is word #success -- then that attachment should not add to that ticket.
When an external sender/vendor replies to the email sent by SNOW with attachments WITHOUT the word #Success, the attachments SHOULD be attached to the ticket in regardless of what format the attachments would be. Email content will still be attached to the ticket, and the activity will have the record of the email
i mean if there is no word #success --then attachment should get attached to the ticket.
can anyone help me achieve this logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 08:24 AM - edited 07-25-2025 08:26 AM
Hi @nivethika,
it does sound like a Business rule onBefore for sys_attachment table with the above conditions
EDIT: please, it shall not be referred as SNOW, instead go with ServiceNow or NOW
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 10:38 AM
Thank you @GlideFather .
this can achieve through business rule or inbound email action?
can you please elaborate in detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 09:04 AM
Hi @nivethika
Check this support article Attachment not moved to customised target record on reply emails - Support and Troubleshooting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 11:09 AM
Hi @nivethika ,
Create an Inbound action try this script:
(function runInboundEmailAction(email, email_action, event) {
var bodyText = email.body_text.toLowerCase();
var hasSuccessTag = bodyText.includes('#success');
gs.info('Inbound email received for ' + email.target + ' with #success: ' + hasSuccessTag);
// attach the email body as comments
var target = email.target;
if (target && target.isValidRecord()) {
target.comments = "Inbound Email:\n" + email.body_text;
target.update();
}
// Check and handle attachments
var attachments = email.getAttachments();
if (hasSuccessTag) {
// Reject all attachments if "#Success" is found
for (var i = 0; i < attachments.size(); i++) {
var attachment = attachments.get(i);
attachment.setState(GlideEmailAttachment.REJECTED);
}
gs.info("Attachments rejected due to presence of #Success in the email.");
} else {
// attachments will be saved by default
gs.info("Attachments will be accepted (no #Success tag found).");
}
})(email, email_action, event);
Please mark this helpful or accept the solution if it is useful.
Thank you