Copy attachment from table a to table b in scoped app

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 11:27 AM
I am trying to copy an attachment from one table to another table in a scoped application. I just can't get it to work. I checked the forum but I don't see what I do differently.
General description of what I am trying to do. I have a parent record that needs to create children for every user entered in the the list. That works perfect without a problem. I just can't copy the attachment(s) from the table that contains the parent record to the the children.
I also was thinking of creating just a http: link(s) to the attachments of the master record but I haven't done this before and would need some pointers.
Script:
Business Rule: Create activity records
When : after, Insert, Update.
(function executeRule(current, previous /*null when async*/) {
var list = current.u_responsible_party.toString();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
if (array[i] != '') {
gr = new GlideRecord('x_conym_gov_req_activity');
gr.addQuery('u_request_number', '=', current.sys_id);
gr.addQuery('u_responsible_party', '=', array[i]);
gr.query();
if (!gr.next()) {
gr.u_request_number = current.sys_id;
gr.u_responsible_party = array[i];
gr.insert();
GlideSysAttachment.copy('x_conym_gov_request', current.sys_id, 'x_conym_gov_req_activity', gr.sys_id);
}
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 01:15 PM
Darla,
As you can see from the script I tried what is described in the link you provided. Have you ever created a link between a table in a scoped application and sys_attachment table?
Armin