Attachment is getting stored on ZZ_YYsc_cart_item not on ZZ_YYsc_req_item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi all,
We have catalog item with attachment variable and attachment is getting stored in sys_attachment table with table name as 'ZZ_YYsc_cart_item' and table sys_id as catalog item sys_id. So that non-admins are unable to download the attachment.
We need to make this attachment to be attached with RITM.Ideally it should get stored in sys_attachment table with table name as ZZ_YYsc_req_item right and table sys_id is RITM sys_id.
You have any idea why it is different in my case and how to attach this to RITM?
Please assist.
Regards,
Saranya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
There is an out of box Business Rule that is supposed to update this record as you expect. You may experience different behavior if the Catalog Item is part of an Order Guide vs not, and/or when ordering through Service Portal/ESC vs the native UI. One solution could be to check the system property named glide.sc.enable_order_now and change the Value to true.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0961833
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @saranyavs
When you upload an attachment inside the Service Catalog form (before submitting), ServiceNow temporarily stores it against the sc_cart_item (Requested Item draft).
That’s why you see the table_name = ZZ_YYsc_cart_item and table_sys_id = sc_cart_item.sys_id.
Once the request is submitted and the RITM (sc_req_item) is created, attachments don’t automatically move to the RITM unless you handle that via script or configuration.
if not moving automatically may you try via script
Most implementations handle this in a Catalog Client Script or Business Rule after the RITM is generated.
For example, using a Business Rule on sc_req_item (after insert):
(function executeRule(current, previous /*null when async*/) {
// Get the cart item that generated this RITM
var cartItem = new GlideRecord('sc_cart_item');
if (cartItem.get(current.getValue('request_item'))) { // ensure link
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id', cartItem.sys_id);
attachment.addQuery('table_name', 'sc_cart_item');
attachment.query();
while (attachment.next()) {
// Copy attachment to the RITM
new GlideSysAttachment().copy('sc_cart_item', cartItem.sys_id, 'sc_req_item', current.sys_id);
}
}
})(current, previous);