Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

hasattachments() giving false on request item

SudhirOjha
Mega Guru

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);

11 REPLIES 11

Mike Patel
Tera Sage

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();

}

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);

 

find_real_file.png

what you get for gs.log("current.request_item " + current.request_item,"test");

RITM0010071 sys_id - 90c6a1c4dba113007821793ebf96194c

find_real_file.png