update the existing attachment by changing the table name to incident and the table sysid to the inc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:12 AM
Hello,
I need help with the below code, i don't use the copy attachment but rather update the existing attachment by changing the table name to incident and the table sysid to the incident sysid. which part of the code to i update this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:19 AM
Hi @Community Alums ,
Please refer to sample code :
Table - Requested Item
When to Run - Before Update
Condition - Send Attachments to True
Scripts -
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var copy = new GlideRecord('problem');
copy.addQuery('parent', current.getUniqueValue());
copy.query();
if (copy.next()) {
GlideSysAttachment.copy('incident', current.getUniqueValue(), 'problem', copy.getUniqueValue());
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:54 AM
can i add this code in the record producer? what i want to achieve is in the sys_attachment table update the table sys id to the incident table for the attachment to show in the incident record.
GlideSysAttachment.copy('sys_attachment', current.attachment.sys_id, 'incident', current.ee.sys_id);
does this make sense?