I want to generate pdf of t a RITM variables

Juhi Jha
Tera Contributor

I want to generate pdf of t a RITM variables 

1 ACCEPTED SOLUTION

Hi,

you can add extra line to download it

var ritmSysId = current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();
var vs = set.getFlatQuestions();

var valuesArray = [];

var csvHeader = [];

for(var i=0;i<vs.size();i++){

	var variableLabel = vs.get(i).getLabel();

	csvHeader.push(variableLabel.toString());

	var variableValue = vs.get(i).getDisplayValue();

	valuesArray.push(variableValue.toString());

}

var csvHeaderRow = csvHeader.toString();
var valueRow = valuesArray.toString();
var sa = new GlideSysAttachment();

var document = csvHeaderRow + "\n" + valueRow;

var ritmRec = new GlideRecord('sc_req_item');
ritmRec.get(ritmSysId);

var sysId = sa.write(ritmRec, "catalog_variables.csv", "text/csv", document);

action.setRedirectURL('/sys_attachment.do?sys_id=' + sysId);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

check this for csv file

Generate csv file with the catalog variables and attaching to RITM record

But for generating pdf file would require to either use Printer friendly version or use custom code

refer below links for help

printer friendly version -

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

custom code

https://community.servicenow.com/community?id=community_question&sys_id=120436711bb9f700d01143f6fe4b...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I don't want user to download PDF from print friendly , after clicking the button it should download pdf which will contain variables 

check other links I shared

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Can you share me the script which will generate variables of RITM in pdf