Copy attachment added via service catalog variable

michelhanna
Kilo Guru

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,

1 ACCEPTED SOLUTION

michelhanna
Kilo Guru

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:

  1. Rename the table name field to remove the ZZ_YY
  2. Use this alternative copy: new global.VariableUtil().(attachmentId, targetTable, targetId); which does NOT add ZZ_YY.

View solution in original post

13 REPLIES 13

Hi Ankur, 

How can I remove ZZ_YY before copying. I written this business rule 

Async - insert. it's not working. can you help?

 

Sneha_Krishna1_0-1694525519516.png

 

If I remove this zz_yy from sys_attachment manually from the table then it's adding the attachment on the case.

Sneha_Krishna1_1-1694525693296.png

 

 

@Sneha_Krishna1 

Can you post a separate question for this and tag me there as this is an older thread?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have posted it but unable to tag you. how can I?

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.

For the second approach what is attachmentId? is it sys_id of the sys_attachment table?