- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 12:01 AM
I have a Display business rule to flag the checkbox "u_has_attachments" on Case task table to check if the record has attachments, but this is not working in Customer service scope and getting an error
"Function hasAttachments is not allowed in scope sn_customerservice"
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 12:09 AM
Hi Nishant
You can Query the attachment table and get the count of attachments
var gr= new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.getValue('sys_id'));
gr.query();
if(gr.hasNext()){
current.u_has_attachments = true;
}
else
{
current.u_has_attachments = false;
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 12:04 AM
Hi Nishant,
Try this before BR
var attachRec = new GlideRecord("sys_attachment");
attachRec.addQuery("table_name", current.getTableName());
attachRec.addQuery("table_sys_id", current.sys_id);
attachRec.query();
if (!attachRec.next()) {
gs.addErrorMessage("You must attach a complete import template before submitting.");
current.setAbortAction(true);
}
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 12:09 AM
Hi Nishant
You can Query the attachment table and get the count of attachments
var gr= new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.getValue('sys_id'));
gr.query();
if(gr.hasNext()){
current.u_has_attachments = true;
}
else
{
current.u_has_attachments = false;
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 04:31 AM
Hi Rohila,
This only works when i update the case task, if i just upload an attachment and do not update the task, the check box remains false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-12-2022 04:58 AM
You should write a BR on attachment table and make the field true/false when user inserts/deletes the attachment.
Check the solution from Ian Mildon in below post
You can try and let us know if you're stuck.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP