Want to provide excel template on catalog item ?

B Ashok
Tera Guru

I want to provide excel template to user's on catalog item, Please help how can I achive this. 

Thanks

Ashok

1 ACCEPTED SOLUTION

Hi Ashok, 

Few more ways to do this and whichever suits your requirements better. 

  • Create this template in the customer's SharePoint and add the link in a field/description of the item so the template can be revised if needed. [BEST SUITED OPTION AS YOU DONT STORE THE TEMPLATE IN SERVICENOW]

  • Create a knowledge article explaining step by step guide and have the document attached to this excel. Explained here in detail.

  • Add the attachment as a link on the catalog item description itself and the template is also stored in the ServiceNow platform, explained here in detail.

  • Mohith has suggested having a new variable created and having the excel attachment show in the form.

 

Hope the answer has helped you, please mark the answer correct/helpful. Thank you.

-Harneet Sital (ServiceNow Certified Technical Architect)

Find all my ServiceNow articles here

View solution in original post

5 REPLIES 5

Mohith Devatte
Tera Sage
Tera Sage

Hello @Ashok B ,

For this you need to create  a widget and tag it to a "Custom" type variable like below 

find_real_file.png

Widget Code:

<div>
  <a href="/sys_attachment.do?sys_id={{data.link}}">Please Click here to donwload</a>

</div>

Server script:

My below script will check for attachment in sys_attachment table with table_sys_id

Table sys_id is nothing but the sys_id of the record where your excel is attached

Here are  the limitation:

1) If you need to embed an excel in catalog item it has to be stored or attached to any record in the instance be it any table but the end user who is clicking on the link to download the excel should have access to read that record .So once attached it will create a attachment record in sys_attachment table with table_sys_id as the attached record sys_id.

2) You might have to change the sys_id in the query every time when you move the code to higher instance because the record for which you have attached might be in DEV or UAT but there is not guarantee that it exists in PROD so you need to do it as a manual step to attach this excel to some record in PROD which the end user can read and then copy the sys_id of the record and change it in script.

OR

you can create a property in sys_properties table  to store the sys_id of the record and when ever the code is move manually update the sys_property value and use it in script below while querying like 

gs.addQuery('table_sys_id',gs.getProperty('your property name'));

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
var gr= new GlideRecord('sys_attachment');
	gr.addQuery('table_sys_id','382c009197741510ae869300f153af73'); //Replace your record sys_id where attachment is attached which end user has access to
	gr.query();
	if(gr.next())
		{
		
			data.link = gr.sys_id.toString();
		}
})();

Then you need  to tag this widget in the custom variable that you have created

find_real_file.png

Output:

find_real_file.png

Please mark my answer correct if it helps you

 

 

 

  

 

Hi Ashok, 

Few more ways to do this and whichever suits your requirements better. 

  • Create this template in the customer's SharePoint and add the link in a field/description of the item so the template can be revised if needed. [BEST SUITED OPTION AS YOU DONT STORE THE TEMPLATE IN SERVICENOW]

  • Create a knowledge article explaining step by step guide and have the document attached to this excel. Explained here in detail.

  • Add the attachment as a link on the catalog item description itself and the template is also stored in the ServiceNow platform, explained here in detail.

  • Mohith has suggested having a new variable created and having the excel attachment show in the form.

 

Hope the answer has helped you, please mark the answer correct/helpful. Thank you.

-Harneet Sital (ServiceNow Certified Technical Architect)

Find all my ServiceNow articles here

@Ashok B Did the answer help you or do you need further help on the query?

 

Hi Mohit, 

Thank you for your inputs this would be helpful. I have achieved my requirement with below article 

https://community.servicenow.com/community?id=community_question&sys_id=134dcfa9db9cdbc01dcaf3231f961977

Thanks