copy attachments from request to RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 11:46 PM
Hi,
I have a requirement to copy all the attachments from Request to the corresponding RITMs.
I have written an After-Insert Business rule on the Request table to achieve the same. But it seems the code is not working as expected.
Name: Copy Attachments to RITM
Table: Request (sc_request)
When to run: After - Insert
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
while(ritm.next())
{
GlideSysAttachment.copy('sc_request', current.sys_id, 'sc_req_item', ritm.sys_id);
}
})(current, previous);
Any lead will be appreciated. Thanks in advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 11:07 PM
Hi Kunal,
Let me know if you need any other assistance on this or please mark it as correct so that others with the same question in the future can find it quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 11:15 PM
Hi Tanumoy,
This works perfectly in ServiceNow native view but not in Portal view (Helsinki version). Any thoughts? Do we need to create a new widget?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 11:31 PM
Hi Kunal,
I don't have much knowledge on Portal View. For business rule I don't think view will be an issue.
But the same thing is working for me in portal view (Geneva).
One more thing, I have done some changes in the script to overcome duplicate issue. You can try that :
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.table_sys_id);
ritm.query();
while(ritm.next())
{
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', ritm.sys_id);
gr.deleteMultiple();
GlideSysAttachment.copy('sc_request', current.table_sys_id, 'sc_req_item', ritm.sys_id);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2016 12:08 AM
Hi Tanumoy,
Thanks for the updated script - I already did that
But still the same issue - this is not working in Portal view (Service Portal, and not the ESS portal)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2018 08:59 AM
Hi Kunal,
Your requirement is exactly what I'm looking for, although the other way around. Did you ever get the attachment to appear in the Portal view?
Thanks