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

log as RITM0010071 and screenshot you shared is RITM0010067. Not sure if RITM0010071 has attachment.

Also try changing order of business rule to 1000 so it runs last.

sorry for incorrect screenshot. But the item has attachment.

FYI- i have changed the order to 1000 also. but still not working

Vipin Murugesan
Kilo Sage

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

find_real_file.png