hasattachments() giving false on request item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:06 PM
creating one business rule which is giving hasattachments() = false despite of having a attachment with record from portal. any idea.
this is created on
Table = sc_task
After insert.
(function executeRule(current, previous /*null when async*/) {
var rec = new GlideRecord('sc_req_item');
gs.log("current.request_item " + current.request_item,"test");
rec.addQuery('sys_id', current.request_item);
rec.query();
gs.log("current attachments " + rec.hasAttachments(),"test");
if(rec.next() && rec.hasAttachments()){
current.work_notes = "RITM number is this:" + rec.number;
current.update();
}
})(current, previous);
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:11 PM
you need to run script against attachment table.
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id', current.request_item);
attachment.query();
if (attachment.next()) {
current.work_notes = "RITM number is this:" + current.request_item.number;
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:17 PM
HI Mike
that attachment.next() is also giving false and its not going inside loop.
(function executeRule(current, previous /*null when async*/) {
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id', current.request_item);
attachment.query();
gs.log("attachment.next() "+attachment.next());
if (attachment.next()) {
current.work_notes = "RITM number is this:" + current.request_item.number;
current.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:25 PM
what you get for gs.log("current.request_item " + current.request_item,"test");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:29 PM