The Now Platform® Washington DC release is live. Watch now!
‎06-03-2019 07:13 AM
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 ?
‎06-03-2019 11:19 AM
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
‎06-03-2019 12:27 PM
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
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();
}
‎06-07-2019 12:02 AM
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.