- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 06:56 PM
Hi,
I'm trying to copy an attachment file from a service catalog attachment variable.
Once the request is submitted, looking at the sys_attachment table, I see the attachment record is added but the table name is ZZ_YYsc_req_item rather than sc_req_item!
I tried both of the below to copy the file with no luck
// try ZZ_YYsc_req_item
GlideSysAttachment.copy('ZZ_YYsc_req_item','sourceSYSID','targetTable','targetSYSID');
//and try sc_req_item
GlideSysAttachment.copy('sc_req_item','sourceSYSID','targetTable','targetSYSID');
EDIT:The copy happens but the table name on the new attachment copy starts with ZZ_YY, even when I don't use that string.
Any ideas how can I copy the attachment variable to a record without the table name starts with ZZ_YY?
Thanks,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 6,412 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 08:30 PM
So, the root cause here is GlideSysAttachment.copy will always cause the new copy to have a table name starts with ZZ_YY for attachments variables, which according to this KB0868420 won't show on the record header.
Two options here to resolve this:
- Rename the table name field to remove the ZZ_YY
- Use this alternative copy: new global.VariableUtil().(attachmentId, targetTable, targetId); which does NOT add ZZ_YY.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 06:35 AM
Hi Ankur,
How can I remove ZZ_YY before copying. I written this business rule
Async - insert. it's not working. can you help?
If I remove this zz_yy from sys_attachment manually from the table then it's adding the attachment on the case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 06:40 AM
Can you post a separate question for this and tag me there as this is an older thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 06:47 AM
I have posted it but unable to tag you. how can I?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 06:18 AM
Hi Ankur,
In my case, my catalog variable attachment is getting store in sys_attachment table with table name as ZZ_YYsc_cart_item and table sys_id as catalog item sys_id.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2021 11:39 AM
For the second approach what is attachmentId? is it sys_id of the sys_attachment table?