Copy attachment from table a to table b in scoped app

Armin Heinlein1
Giga Expert

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);

5 REPLIES 5

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