Embedding an attachment or link to an attachment on a form

michaelmonocchi
Kilo Expert

Running Geneva version and we are fairly new to ServiceNow. We have a Service Request Catalog item for department moves. Along with the form users fill out, we need an Excel spreadsheet to be completed. Is there any way to somehow embed this attachment in the form and make it part of the form all the time, or have a link the user can click to get to the form? If this is possible, we are also trying to figure out a way to keep the user from submitting the request if the spreadsheet is not attached.

1 ACCEPTED SOLUTION

rlatorre
Kilo Sage

We handle making attachments available using this method:



  • Attach file to the appropriate record
    • Example: Document linked from a Catalog Item is attached the the item record (sc_cat_item)
  • Save record
  • Use the "view" link to open the attachment
  • Obtain the attachment SysID from the end of the URL
  • Create a URL link substituting this SysID:
    • In a Rich Text field using this format:
      sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true
      • Full HTML:
        <a href="https://<your_instance>.service-now.com/sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true" target="_blank">My Link</a>
    • Hyperlink in external document (include the instance):
      https://<your_instance>.service-now.com/sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true


You can place the link in the item Description for the user to download, fill-out, save locally and attach before submission.



To require an attachment before submission see this onSubmit Client Script:



function onSubmit() {


  var producer_id = gel('sysparm_item_guid').value;


  var gr = new GlideRecord('sys_attachment');


  gr.addQuery('table_name', 'incident');


  gr.addQuery('table_sys_id', producer_id);


  gr.query();


  if (!gr.next()) {


  alert("Message instruction the user to fill-out the attachment");


  return false;


  }


}



Please mark as Answers if this meets your requirements.


View solution in original post

5 REPLIES 5

Chuck Tomasi
Tera Patron

Hi Michael,



My recommendation is stick with the paperclip icon for consistency. If you start bringing attachment elements to the main form, it can be inconsistent and confusing. Use annotations if you need to provide users with additional instructions.



You might find the following helpful.



Make Attachment Mandatory - For A particular Catalog Item



Annotating Forms - ServiceNow Wiki


rlatorre
Kilo Sage

We handle making attachments available using this method:



  • Attach file to the appropriate record
    • Example: Document linked from a Catalog Item is attached the the item record (sc_cat_item)
  • Save record
  • Use the "view" link to open the attachment
  • Obtain the attachment SysID from the end of the URL
  • Create a URL link substituting this SysID:
    • In a Rich Text field using this format:
      sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true
      • Full HTML:
        <a href="https://<your_instance>.service-now.com/sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true" target="_blank">My Link</a>
    • Hyperlink in external document (include the instance):
      https://<your_instance>.service-now.com/sys_attachment.do?sys_id=43f614050a0a0b846fc33c7021c00455&view=true


You can place the link in the item Description for the user to download, fill-out, save locally and attach before submission.



To require an attachment before submission see this onSubmit Client Script:



function onSubmit() {


  var producer_id = gel('sysparm_item_guid').value;


  var gr = new GlideRecord('sys_attachment');


  gr.addQuery('table_name', 'incident');


  gr.addQuery('table_sys_id', producer_id);


  gr.query();


  if (!gr.next()) {


  alert("Message instruction the user to fill-out the attachment");


  return false;


  }


}



Please mark as Answers if this meets your requirements.


Thanks Robert. We did stumble on the script and we were able to figure out how to attach an Excel doc to the Service Request form. Thanks for that info. Our next challenge is to make it easy for users to attach the Excel doc to the form. There is no attachment icon on the form in the ESS portal so we searched and found a Catalog Client Script that puts an attachment link in the upper left corner of the form. Users can click this and attach their Excel doc.



Problem now is the formatting of the link is not correct. The bottom of the text is getting clipped. I posted this in Text getting clipped at bottom on Service Catalog page



Maybe you have a suggestion for this also. I have played with the code and settings with no success. It looks worse in IE then it does in Chrome. It's usable, it just does not look good.


Did you try changing the height style in that code?



You can also try a macro variable "portal_attachment_entry". I think it's OOB but I attached it.



We place this in a variable set to relate to items and record producers to appear at the bottom of the forms. You can add a label to give further instruction.