- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 04:56 AM
Can we write GlideSysAttachment.copy in business rule which does not runs on sys_attachment table?.. Or it can be only written on sys_attachment table?.
I have been trying to write it on sc_req_item table.. but it does not copy the attachment!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 05:11 AM
Here is an example, copying attachments from one incident record to another.
var sourceSysID = '9c573169c611228700193229fff72400';
var targetSysID = '9d385017c611228701d22104cc95c371';
var copyAtt = new GlideSysAttachment();
copyAtt.copy('incident',sourceSysID, 'incident',targetSysID);
If it was in a a br and I want to copy from lets say to current incident record to the record in the parent incident field it could look like this:
var copyAtt = new GlideSysAttachment();
copyAtt.copy('incident',current.getUniqueValue(), 'incident',current.getValue('parent_incident'));
And make this a async BR for performance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 05:02 AM
yes, you can use the function on other tables.. can you show us the code you done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 05:09 AM
when to run:
before insert
order= 100
table: sc_req_item
script:
var id=current.variables.psa_ritm_id; // this is a variable in the catalog item form which gives the ID of the RITM which has the attachment
gs.log(' id in Url '+id);
if(id){ // if id is present
gs.log('current id '+current.sys_id);
GlideSysAttachment.copy('sc_req_item', 'id', 'sc_req_item', 'current.sys_id'); //copy the attrachment
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 05:13 AM
did a few changes. I take that the variable holds the sys_id of the source record. and not a number like RITM002343
var id=current.variables.psa_ritm_id; // this is a variable in the catalog item form which gives the ID of the RITM which has the attachment
gs.log(' id in Url '+id);
if(id){ // if id is present
gs.log('current id '+current.sys_id);
var copyAtt = new GlideSysAttachment();
copyAtt.copy('sc_req_item', id, 'sc_req_item', current.getUniqueValue()); //copy the attrachment
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 05:11 AM
Here is an example, copying attachments from one incident record to another.
var sourceSysID = '9c573169c611228700193229fff72400';
var targetSysID = '9d385017c611228701d22104cc95c371';
var copyAtt = new GlideSysAttachment();
copyAtt.copy('incident',sourceSysID, 'incident',targetSysID);
If it was in a a br and I want to copy from lets say to current incident record to the record in the parent incident field it could look like this:
var copyAtt = new GlideSysAttachment();
copyAtt.copy('incident',current.getUniqueValue(), 'incident',current.getValue('parent_incident'));
And make this a async BR for performance.