Attachment Added Event Working in Backend but Not Triggering from Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi All,
I created an Event + Business Rule on sys_attachment (After, Insert) to trigger an email notification when an attachment is added to sc_req_item (RITM).
It works correctly when attachment is added from the backend form view.
However, when attachment is added through Service Portal, the event is not firing and notification is not triggered.
Attachment record is getting created in sys_attachment with correct table_name and table_sys_id.
Business Rule details:
Table:
sys_attachmentWhen: After
Insert: ✔
Advanced: ✔
this is the script(function executeRule(current, previous) {if (!current.table_sys_id)return;// RITMif (current.table_name == 'sc_req_item') {var ritm = new GlideRecord('sc_req_item');if (ritm.get(current.table_sys_id)) {gs.eventQueue('attachment.added',ritm,ritm.sys_id,current.file_name);gs.log('RITM Attachment Event Fired: ' + ritm.number);}}// Incidentif (current.table_name == 'incident') {var inc = new GlideRecord('incident');if (inc.get(current.table_sys_id)) {gs.eventQueue('attachment.added.incident',inc,inc.sys_id,current.file_name);gs.log('Incident Attachment Event Fired: ' + inc.number);}}})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @JyotiranjanC566 ,
Could you please try with Async instead of after business rule and check.
Also , you can check following KB Article "After Insert Business rule on sys_attachment table does not execute when records are created through..."
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2208821
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
hey @JyotiranjanC566
Instead of loading the target record again using GlideRecord and passing sys_id as event parameters.
Business Rule
(function executeRule(current, previous) {
if (!current.table_sys_id)
return;
if (current.table_name == 'sc_req_item') {
var ritm = new GlideRecordSecure('sc_req_item');
if (ritm.get(current.table_sys_id)) {
gs.eventQueue(
'attachment.added',
ritm,
current.file_name,
''
);
gs.log('RITM Attachment Event Fired: ' + ritm.number);
}
}
else if (current.table_name == 'incident') {
var inc = new GlideRecordSecure('incident');
if (inc.get(current.table_sys_id)) {
gs.eventQueue(
'attachment.added.incident',
inc,
current.file_name,
''
);
gs.log('Incident Attachment Event Fired: ' + inc.number);
}
}
})(current, previous);***********************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh

