- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 07:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 07:40 AM
Hi Praveen,
I assume you want attachment to be copied over from SC Task to RITM when attachment is added
sample BR on sys_attachment; It would be copying all attachments to RITM from SC TASK
BR: after insert on sys_attachment
Condition: current.table_name == 'sc_task'
Script:
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery('sys_id', current.table_sys_id);
taskRec.query();
if(taskRec.next()){
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.addQuery('sys_id',taskRec.request_item);
ritmRec.query();
if(ritmRec.next()){
GlideSysAttachment.copy('sc_task', current.table_sys_id, 'sc_req_item', ritmRec.sys_id);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 07:40 AM
Hi Praveen,
I assume you want attachment to be copied over from SC Task to RITM when attachment is added
sample BR on sys_attachment; It would be copying all attachments to RITM from SC TASK
BR: after insert on sys_attachment
Condition: current.table_name == 'sc_task'
Script:
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery('sys_id', current.table_sys_id);
taskRec.query();
if(taskRec.next()){
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.addQuery('sys_id',taskRec.request_item);
ritmRec.query();
if(ritmRec.next()){
GlideSysAttachment.copy('sc_task', current.table_sys_id, 'sc_req_item', ritmRec.sys_id);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 07:45 AM
Hi Ankur,
Need it for one catalog item only not for globally?
How we can do it.
Thanks in Advance
Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 07:48 AM
You can just add in the condition of the BR something like this:
current.request_item.cat_item == 'sys ID of your item'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 08:02 AM
Hi Praveen,
update as below
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.addQuery('sys_id',taskRec.request_item);
ritmRec.addQuery('cat_item.name', 'YOUR CATALOG ITEM NAME HERE');
ritmRec.query();
if(ritmRec.next()){
GlideSysAttachment.copy('sc_task', current.table_sys_id, 'sc_req_item', ritmRec.sys_id);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader