- 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-29-2023 01:45 PM
If you want to copy the attachment only on insert, It should be an after Insert BR.
If you want to copy attachment, when the approval is approved, you should have an after Update BR, with condition state changed to Approved.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 01:50 PM
Hello @SanjivMeher
Thanks for the quick reply!
Issue
1.If approver attached attachment its pasting on the CR table.
and whenever i added a comment all the time same attachment is attaching .
Its "like comment - attachment - repeat"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 01:56 PM
May be because you dont have a condition in the Business Rule.
It should only copy when the state changes to Approved.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-29-2023 02:11 PM
Hello @SanjivMeher ,
copy when the state changes to Approved is working
but after insert is not working?
Is it possible to achieve copy and paste attachment only one time?
whether its open state?
please help on this.thanks!