The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Add record to sys_attachment table

dioni95
Kilo Expert

Hi all, 

I need to add an attachment to one catalog item at service portal so the end user can download it. I have the next script to do it.

find_real_file.png  

It takes a record from sys_attachment table (href="/sys_attachment.do?sys_id=57b0583edbe60700c6efdd3b5e961977"), but I need to modify that file and I go to the table and I can´t modify it or create a new attachment.

find_real_file.png

I read a lot of information this week, but I didn't find something to help me.

If you know where or how I can create a new attachment record or modify the existing, please let me know.

Thanks in advance.

1 ACCEPTED SOLUTION

harshinielath
Tera Expert

var sourceSysID = '1db6b56e6fa58f4882d1cf164b3ee4bf';
var targetSysID = current.sys_id;
var copyAtt = new GlideSysAttachment();
copyAtt.copy('kb_knowledge', sourceSysID, 'sc_req_item', targetSysID);

Here is the script I used in workflow to attach files in Service Catalog Request Items. Modify this script for your tables and see if it works. This is not the ideal way but a workaround I found to do it after trying so many other ways.

I have the attachment in Knowledge base and use it to attach for request items of specific catalog item. Let me know if you have any questions.

View solution in original post

6 REPLIES 6

Thank for your attention. 

I have a question, If you can response It would wonderful.

How can I upload a new attachment? I mean, to do that do I need a script or can I upload it from attachment's table or other table?

Thank again 🙂 

 

DB1
Tera Contributor

Hi,

Can I use the above logic for "sys_metadata" table. 

If so , need some insights on the same please