- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 08:01 AM
I have a form where the user is able to attache documents. After pressing submit, I'm trying to get the attachments so I've created a business rule "Running after insert" for sc_req_item table.
I'm trying to see if I can find the attachment but i'm not able to find the current one. If I'm looking for an older attachment it works perfectly. I guess that when I'm trying to find the current.sys_id is not already created in the table. But is there a way to find it?
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('table_name', current.getTableName());
gr.query();
if (gr.next()){
gs.info(' record FOUND');
}
else{
gs.info(' record not found');
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 01:24 PM
Why do you want to check the attachment? What happens, if you make the business rule async?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 01:24 PM
Why do you want to check the attachment? What happens, if you make the business rule async?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2018 06:31 AM
Hi Sanjiv. It worked after I made the business rule async. Thanks for your answer!