- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:20 PM
Hi Guys,
I am not sure why but GlideSysAttachment.copy isn't working for me. There is a requirement where I need to copy the attachment of a requested item into a catalog task for a specific catalog items and this isn't working. I already tried using background scripting and it isn't working either:
Type - Business Rule
Runs on - sc_task
When - after, insert
function onAfter(current, previous) {
//This function will be automatically called when this rule is processed.
gs.log('request item sys_id ' + current.request_item);
gs.log('catalog task sys_id ' + current.sys_id);
var gr = new GlideRecord('sys_attachment');
gr.addQuery ('table_sys_id', current.request_item);
gr.addQuery ('table_name', 'sc_req_item');
gr.query();
if (gr.next()){
gs.log('record found');
GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_cat_task', current.sys_id);
}
}
Could you please review and see if I am missing something?
Mussie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:48 PM
In other words... line 14 will be:
GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:40 PM
Is this in a scoped application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:47 PM
Hi Mussie, your error is on the name of the catalog task.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:47 PM
It should be sc_task.
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 07:50 PM
Lol, I have missed the obvious, need to stop thinking too much.