Best way to handle attachments in serviceportal

Felix20
Mega Guru

Hi everybody,

i have a page on which is a textarea field and and a input field for files. I know there is a snattachhandler but that handler uses a table and an entry to attach it to, but at the time the use presses the button there is no enrry.

what is the best way to handle attachments in serviceportal pages? When i use a custom widget without form?

 

Best regards,

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

There may be an external library you could use. Also, if you want to use the default functionality but it requires a record to be created, why not create the record at the time someone uploads an attachment? It's going to need to be associated with a record eventually anyway, right? If they end up abandoning the form you could do some sort of scheduled cleanup of those records.

View solution in original post

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

There may be an external library you could use. Also, if you want to use the default functionality but it requires a record to be created, why not create the record at the time someone uploads an attachment? It's going to need to be associated with a record eventually anyway, right? If they end up abandoning the form you could do some sort of scheduled cleanup of those records.

Hi Brad,

yes I want to create a record based on that textarea field - work order with description and just want to attach the uploaded file / image.

Now I tried using snAttachmentHandler to write attachment on wm_order and with sys_id -1. It creates an entry in sys_attachment that is good and right file is available. but know i need to use GlideSysAttachment to copy that file to my workorder and delete that temporary file. 

What would you suggest to script?

Having an textarea field + a upload icon (input type file) and a button Submit -> which just creates a new work order and attching that attachment which has been uploaded?

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would use GlideSysAttachment to copy. What have you tried so far?

Do you mean to copy the saved -1 attachment in sys_attachment?

That is not working because its not really an attachment but just a table entry.