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

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.

Thank for your attention, let me try this method.

Thanks I did it. I upload the attachment in Knowledge base and then use it. 

Jon Barnes
Kilo Sage

Yes, if you go to the list of attachments, and click it, it will download it. There is no OOB method for editing attachments. They really can only be downloaded and uploaded / deleted.

 

You can do it through script, but not manually like that.