How to check if the Attachment is empty in Record?

IG3
Tera Contributor

Hello Community,

I have a Business Rule and in this Business Rule after the "state" change to "documented" I want check the attachment.
My question is how can I check if the attachment is empty?

I would like to do something like this 
If ( ' attachment '  == empty) 
gs.addInfoMessage("attachment is empty);

1 ACCEPTED SOLUTION

Viraj Hudlikar
Giga Sage

Hi IG,

Please try below code.

var grAttch = new GlideRecord('sys_attachment');
grAttch.addQuery('table_sys_id',current.sys_id); // get attcahments for current incident
grAttch.query();
if(grAttch.next()){ //attachment exist
//perform your further action.		
}
else{
//perform action when attachement is not present.
}

 

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.

Thanks & Regards,
Viraj Hudlikar.

View solution in original post

1 REPLY 1

Viraj Hudlikar
Giga Sage

Hi IG,

Please try below code.

var grAttch = new GlideRecord('sys_attachment');
grAttch.addQuery('table_sys_id',current.sys_id); // get attcahments for current incident
grAttch.query();
if(grAttch.next()){ //attachment exist
//perform your further action.		
}
else{
//perform action when attachement is not present.
}

 

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.

Thanks & Regards,
Viraj Hudlikar.