How to add a link in a form to download the pdf

Amol Pawar
Tera Guru

Hi Experts,

 

I have a requirement mentioned below. Please go through it and let me the best possible solution:

I want to create a link in a form to download a PDF. It should be in the form of a record of a table, not a record producer. So I'm unable to use the 'Rich text label'. In table level, which field type I can use to give a downloadable link in a form?

 

Thanks in advance,

Amol

 

1 ACCEPTED SOLUTION

Rajdeep Ganguly
Mega Guru


Sure, you can use the URL field type to create a downloadable link in a form. Here are the steps:

1. Navigate to the table where you want to add the URL field.
2. Click on "Configure" -> "Table".
3. In the Columns section, click on "New" to add a new field.
4. In the Label field, enter the name of the field.
5. In the Type field, select "URL".
6. Fill in the rest of the fields as necessary and click "Submit".
7. Now, you can use this field to store the URL of the PDF file. When you view a record, this field will appear as a clickable link that will open the PDF file in a new tab.

Please note that the URL must be publicly accessible. If the PDF file is stored in ServiceNow, you can use the sys_id of the file in the sys_attachment table to construct the URL. The format of the URL is https://.service-now.com/sys_attachment.do?sys_id=.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

View solution in original post

4 REPLIES 4

Hi @kps sumanth,

Thank you for your reply but the link you provided is not the direct reference.

Please provide me with any other solution if you have.

Thanks,

Amol

Anand Kumar P
Giga Patron
Giga Patron

Hi @Amol Pawar ,

 

You can create a UI Action form button with the folowing script to export the form to pdf :-

 

Client : ticked

Form Button : ticked or form link

Onclick : exportPDF()

 

Script :

 

function exportPDF() {
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
var a='https://dev00000.service-now.com/';
var url = a+sysparm_table + '.do?PDF&sys_id=' + sysparm_sys_id;
g_navigation.openPopup(url);

 

NOTE : In var a write your own developer instance url.

For custom url on form-

https://www.servicenow.com/community/developer-articles/adding-a-ui-action-link-as-field-type-for-bo... 

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Rajdeep Ganguly
Mega Guru


Sure, you can use the URL field type to create a downloadable link in a form. Here are the steps:

1. Navigate to the table where you want to add the URL field.
2. Click on "Configure" -> "Table".
3. In the Columns section, click on "New" to add a new field.
4. In the Label field, enter the name of the field.
5. In the Type field, select "URL".
6. Fill in the rest of the fields as necessary and click "Submit".
7. Now, you can use this field to store the URL of the PDF file. When you view a record, this field will appear as a clickable link that will open the PDF file in a new tab.

Please note that the URL must be publicly accessible. If the PDF file is stored in ServiceNow, you can use the sys_id of the file in the sys_attachment table to construct the URL. The format of the URL is https://.service-now.com/sys_attachment.do?sys_id=.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER