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:42 PM
log as RITM0010071 and screenshot you shared is RITM0010067. Not sure if RITM0010071 has attachment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:42 PM
Also try changing order of business rule to 1000 so it runs last.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 01:05 PM
sorry for incorrect screenshot. But the item has attachment.
FYI- i have changed the order to 1000 also. but still not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:29 PM
Hi,
To check if your request_item has attachment or not,
Follow these steps:
create Display business rule on sc_req_item Table.
and add script as follows:
g_scratchpad.hasAttachments = current.hasAttachments();
and now after saving business rule, create OnLoad Client script and add script as follows:
if (g_scratchpad.hasAttachments)
{
alert("yes attachment is present");
}
else
{
alert("No attachment is not present");
}
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-13-2018 12:30 PM