Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Download file on catalog

Shabbir1
Tera Contributor

Hello Team,

 

We have requirement that "Document" is a drop down variable on the service catalog if you select the 'yes' in that variable we need to show the document link type or name. If you click on that link document should be downloaded(Business has given the word doc) and user will fill the data and attach this doc in the attachment and submit the catalog can anyone suggest how to achieve this kindly help us in scripting or any other best salutation

2 REPLIES 2

AlwinJebakY
Tera Expert

Hi @Shabbir1 ,

Create the following three catalog variables:

  1. Select Box – Options: Yes / No
  2. Rich Text Label – Provide the Word document download link
  3. Attachment – Allow the user to upload the completed document

Create a Catalog UI Policy with the condition Document is yes. When true:

  • Show the Rich Text Label.
  • Show the Attachment variable.
  • Make the Attachment variable mandatory.

When Document is no, hide the download link and Attachment variable and make the attachment non-mandatory.

Tanushree Maiti
Tera Patron

Hi @Shabbir1 

 

Step 1.  Create the Variables

  1. Variable 1:
    • Type: Select Box (Dropdown)
    • Name: u_need_document
    • Question: Do you need the document template?
    • Choices: Add two choices: Yes and No.
  2. Variable 2:
    • Type: Rich Text Label (Recommended) or HTML
    • Name: u_document_download_link
      • Label / Text: Use the HTML editor to format a clean link. //click on  code view (<>) icon and add your code:

html

<a href="/sys_attachment.do?sys_id=<YOUR_COPIED_SYS_ID_HERE>" target="_blank" download>

   Click here to download the required Word Document template

</a>

 

Step 2: Create a Catalog UI Policy

To control the visibility so the link only shows when the user selects 'Yes':

  • On your Catalog Item, scroll down to the Catalog UI Policies related list and click New.
  • Short Description: Show document link when 'Yes' is selected.
  • Conditions: Set the condition to: [u_need_document] [is] [Yes].
  • Click Submit

In the Catalog UI Policy Actions related list at the bottom, click New.

  • Select your link variable (u_document_download_link).
  • Set Visible to True.
  • Set Mandatory and Read Only to Leave alone or False.
  • Click Submit.

 

Step 3: Ensure Attachments are Enabled

  • Open the main Catalog Item record.
  • Ensure that the Hide Attachment checkbox is unchecked.

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti