Copy attachments from one catalog task to another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 12:39 AM - edited 09-14-2023 09:01 PM
I have 4 catalog tasks, I want to copy all attachments from Task 1--> Task 2---> Task 3 --> Task 4 ---> Task 5.
Wrote a Before insert BR on sc_task table with condition as Cat item is "ABC" and State is 'Open'
var task = new GlideRecord('sc_task');
task.addQuery('request_item',current.request_item);
task.query();
if(task.next()){
gs.addInfoMessage('Triggered');
GlideSysAttachment.copy('sc_task', task.sys_id, 'sc_task',current.sys_id);
}
It goes inside if condition but not copying attachment
How can i achieve this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 08:29 AM
Well, then my only response is this: TNT: The Customer is NOT Always Right
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 09:37 PM
This will unnecessarily increase the attachment table size since same file will be replicated at 5 different places
you can do this if you still require this in before insert or after insert BR on sc_task
var task = new GlideRecord('sc_task');
task.orderByDesc("sys_created_on");
task.addQuery('request_item',current.request_item);
task.setLimit(1);
task.query();
if(task.next()){
gs.addInfoMessage('Triggered');
GlideSysAttachment.copy('sc_task', task.sys_id, 'sc_task',current.sys_id);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader