How to Check if an attachment has been added by agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 04:43 AM
Hi All,
I have a requirement to check "If an attachment has been added by an agent(Assigned To) user to a case " if yes then trigger the notification.
Can someone help with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 03:01 AM
try this and it will check if attachment created by is not equal to case assigned to
var erCase = new GlideRecord('sn_hr_er_case');
if (erCase.get(current.table_sys_id) && current.sys_created_by != erCase.assigned_to.user_name.toString()) {
gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 05:36 AM - edited 06-24-2025 05:49 AM
Hi @sanvi , In your original post, it is written that event will be triggered if attachment is added by assigned to. Now try this,
By below code, event will be triggered if attachment is added but not added by assigned to, try
var caseGR = new GlideRecord('sn_hr_er_case');
if (!caseGR.get(current.table_sys_id)) {
return;
}
if (caseGR.assigned_to.user_name.toString() != current.sys_created_by.toString()) {
//this condition will check if attachment is not added by assigned_to
gs.eventQueue('sn_hr_er.add_attachment', erCase, current.file_name);
}
And Mark the response as helpul/correct if i could help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 06:07 AM
you can use advanced notification condition and check if record has attachment or not
how are you triggering email?
what's your business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader