- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 12:27 AM
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);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Studio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 12:39 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 12:39 AM
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.