Copy attachment from RITM to data source - GlideSysAttachment().copy not working !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 12:28 AM
Hi All,
I have one requirement to copy the attachment from one table to another table.
Requirement : Whenever a request is placed from catalog item(from only one item),attachment from RITM should be copied to data source table, to a particular data source record. In my case data source record name is TEST and sys_id is 0ec1ab04db8bbf4019d81ffa68961900.
I have created below Business Rule to achieve this, but its not working .[working only for after update condition not after insert] attachment is not getting attached on TEST data source.
(function executeRule(current, previous /*null when async*/) {
gs.log("Start");
var sourceSysID = current.sys_id ;
var targetSysID = '0ec1ab04db8bbf4019d81ffa68961900'; //target record ID
var copyAtt = new GlideSysAttachment();
copyAtt.copy('sc_req_item', sourceSysID, 'sys_data_source', targetSysID);
})(current, previous);
BR screenshots has been attached.Can anyone help me to achieve this?
Thanks in Advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 03:47 AM
added Asifnoor.Its working only for after update condition not for after insert condition.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 04:01 AM
Yes, thats how it works.
As i said, when you upload an attachment, it is considered to update. Bcoz first attachment will be added in sys_attachment table, but table_sys_id and table_name will be added again as an update. And you can copy only after you have table_sys_id and table_name. Hence you need to use after update.
Kindly mark the comment as a correct answer and also helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 04:52 AM
ok.Then How can I copy the attachment for after insert?That is how my requirement is.Is it not possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2019 05:05 AM
Asifnoor I have changed the "When to run condition" to "async",now its working for insert as well.Now the issue is while insert ,attachment is getting attached 2times.
Do you have any idea on this?