The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I want to generate PDF file with current RITM fields info & Variables information and associated Approvals information???

Shantharao
Tera Guru

I want to generate PDF file with current RITM fields info & Variables information and associated Approvals information?

If I attach an Excel sheet with some data that could be parsed to table format to the current RITM record

 

How can I generate pdf with current record information ?? and How can I parse attached excel sheet data to table format into the same record ?

3 REPLIES 3

Shantharao
Tera Guru

as a work around below code is working only for Incident table but not working for "sc_req_item" table, what is the reason?

 

function pdf1(){
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
var a='https://dev78905.service-now.com/';
var url = a+sysparm_table + '.do?PDF&sys_id=' + sysparm_sys_id+'&sysparm_view='+ sysparm_view;
window.open(url);

}

 

Can any one provide me the exact code for attaching ritm & varibles & approvals information for a current RITM record..

does it possible without any paid plugins?

 

Thanks

The below code is working fine good

 

 

The solution below is server side script that can be used as e.g.Business Rule or in Script include.

 

Requirements:

You need to create a basic authentication profile (Create a basic auth profile) and since this might differ between your instances - let's put it in a system property.

Version: london

 

steps to be follwed
I have created one Rest Message record and 
I have created one basic authuntication profile 
clicked on new and created new authuntication profile(admin,web_service_admin) 
copied basic auth profile sys'_id in below property 
and created one property called : com.customer.pdf.authprofile

 

 BUsuness Rule

var basicAuthProfileSysID = gs.getProperty('com.customer.pdf.authprofile');

generateAndStoreAttachment('incident', current.sys_id, 'Default', current.sys_class_name, current.sys_id,'Incident_Export.pdf', basicAuthProfileSysID);

 

/**

* Gets a PDF from a record form view and stores it as an attachment to the same record.

* Uses RestMessageV2 for getting the attachment via HTTP Call.

*

* All parameters are mandatory.

*

* @param   {String} pdfTable                     Table of the record to be generated.

* @param   {SysID}   pdfSysID                     Sys ID of the record.

* @param   {String} view                             View that should be used for generation of PDF

* @param   {SysID}   attachToTable           Class name/table name to which the record should be attached.

* @param   {SysID}   attachToSysID           Sys ID of the record that generated file should be attached to

* @param   {String} fileName                     Target file name.

* @param   {SysID} authProfileSysID       SYSID of the profile to be used for authentication.

* @return null

*/

function generateAndStoreAttachment( pdfTable, pdfSysID, pdfView, attachToTable, attachToSysID, fileName, authProfileSysID ) {

      var r = new sn_ws.RESTMessageV2();

      r.setHttpMethod('get');

      r.setEndpoint('https://'+gs.getProperty('instance_name')+'.service-now.com/' + pdfTable + '.do?PDF&sys_id=' + pdfSysID + '&sysparm_view=' + pdfView);

      r.setAuthenticationProfile('basic', authProfileSysID);

      r.saveResponseBodyAsAttachment(attachToTable, attachToSysID, fileName);            

      var response = r.execute();            

      //response.getStatusCode();

}

 

Hi Harish,

 

function pdf1(){
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
var a='https://dev78905.service-now.com/';
var url = a+sysparm_table + '.do?PDF&sys_id=' + sysparm_sys_id+'&sysparm_view='+ sysparm_view;
window.open(url);

}

 

i am using above scenario. it is working fine but my latest requirement is filename should change based on timestamp.

how to change file name please help me.

 

Thank you.