Attachment Macro on UI page?

straightforward
Kilo Explorer

Dear community,

I am working on an UI page that will ultimately create or update records. One part of the requirements for this is the ability to:

1) Upload attachments when creating a record

2) View current attachments and upload new attachments when updating a record

I have looked within the UI macro section but have not found anything that would do this for me. Also I am wondering how an attachment upload would even work when the record is not even created yet.

Does anyone have an idea of how this can be achieved in a straightforward manner??

Best,

Chris

6 REPLIES 6

uluerje
Mega Expert

I use this macro on forms to give users a larger icon they can use to add attachments instead of having to find the tiny one in the upper right-hand corner.   It works on new records (before there's a unique key) so maybe it'll work for you.



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<b>Add Attachments</b><br/>


<a onclick="saveAttachment(g_form.getTableName(), g_form.getUniqueValue())">


<img src="file-attachments.jpg" width="60" height="78"/></a>


<b></b>


</j:jelly>


What I realize from this is that there seems to be a servicenow function called saveAttachment(tablename, sys_ID). The first question now is from which fields it pulls the actual files to upload and if this can somehow be transferred to UI pages as well(?) I've been trying for a couple of hours now but haven't really gotten anywhere with it



The second question is how to attach files to a record/sys_id that does not even exist yet (if the UI page form is used to create a record from scratch). From a logical perspective I would probably create the record first and then do a subsequent update on that record with the attachments?



Bottom line, any further help and insight on this attachment/UI page issue is highly appreciated!


Is there a reason why you aren't just using a record producer to submit a ticket on the UI page?


User749558
ServiceNow Employee
ServiceNow Employee

Hi Jessica,



I have the same requirement that user should be able to attach a document in UI page, which will be a public page. The use case is that Job Applicant will apply for a job using public page, where in applicant needs to attach his/her resume.



Please help me on this.