- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 04:15 AM
Hi All,
I have written a Business rule to copy attachment from sys_attachment to hr_case table when someone sends and attachment via the email client template on a hr record.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var sys_id=current.sys_id;
if(current.target_table=="hr_case"){
var gr= new GlideRecord('sys_attachment');
gr.addQuery("table_sys_id",sys_id);
gr.query();
if(gr.next()){
GlideSysAttachment.copy('sys_attachment', gr.sys_id, current.target_table, current.instance);
}
}
gs.info("completed");
})(current, previous);
But it is not working. I cannot see any attachment on HR Case table.
Also in the logs I see the following warning : "syslog_transaction not found for AjaxClientTiming: sysId: , table: , view: Default view, form: email_client_template"
Any help would be appreciated
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 04:20 AM
Hi Sidarth,
The key to making this work is to find out what the real record is that the attachment is linked to. The attachment is IN sys_attachment, but it is not attached to a sys_attachment record.
If you look in sys_attachment for that record, you will see the table name (see example image below.)
THAT is going to be your source table and sys_id to use in the first arguments. The target table will be the current record's information (see 3rd and 4th args below.)
GlideSysAttachment.copy(sourceTable, sourceSysId, current.getTableName(), current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 07:15 AM
Thanks for the clarification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 04:23 AM
Hi Sidarth,
You won't be able to copy from sys_attachment table. From sys_attachment find out on which record of which table the attachment is attached to and copy it from there to your hr_case table.
Regards,
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 03:42 AM
Did you resolve this ?