- 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
ā12-01-2023 05:37 AM
Hello @Ankur Bawiskar ,
Thanks for the reply!
I have followed modified the @dhanu3 script is working fine now.Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-01-2023 05:42 AM
@akin9 Please mark the answer as correct if it have solved your issue.