- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 01:41 PM
Hello Experts,
We want to copy attachments from "sysapproval_approver" table to change request table.
i have created below GlideSysAttachment.copy code is working fine.
but issue is whenever record is inserted or updated copying all attachments every time.
Requirement1.If approver attachment should copy only one time.
Please support me on this
Table =sysapproval_approver
After insert or update BR.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var chg = new GlideRecord('change_request');
if(chg.get(current.sysapproval)){
var attachment = new GlideSysAttachment();
attachment.copy("sysapproval_approver",current.sys_id,"change_request",chg.sys_id);
}
})(current, previous
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 11:25 PM
@akin9 condition is correct. Please try with below code.
var sy = new GlideRecord('sysapproval_approver');
sy.get(current.table_sys_id);
var changeSysID = sy.sysapproval;
var ch = new GlideRecord('change_request');
ch.get(changeSysID);
var attachment = new GlideSysAttachment();
attachment.deleteAll(ch);
attachment.copy("sysapproval_approver", current.table_sys_id, "change_request", changeSysID);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 12:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 12:41 AM
After insert BR on sys_attachment table and in condition select table name is sys_approval and then you code to get sys id of change request and to copy attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 02:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 11:25 PM
@akin9 condition is correct. Please try with below code.
var sy = new GlideRecord('sysapproval_approver');
sy.get(current.table_sys_id);
var changeSysID = sy.sysapproval;
var ch = new GlideRecord('change_request');
ch.get(changeSysID);
var attachment = new GlideSysAttachment();
attachment.deleteAll(ch);
attachment.copy("sysapproval_approver", current.table_sys_id, "change_request", changeSysID);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 05:40 AM
Hello @dhanu3 ,
After insert -
after insert on sys_attachment
Condition: current.table_name == 'sysapproval_approver'
I have followed the above working fine.