Auto generate PDF of RITM with related list and attach to the RITM itself
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I want to auto generate a PDF whenever the request is completed and auto attach the PDF to the actual RITM.
The PDF should contain all variable information along with the Approver related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
My Apologies @Aditya_hublikar but still there are no variables details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @mr18 ,
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var v = new sn_pdfgeneratorutils.PDFGenerationAPI();
var gr = new GlideRecord("sc_req_item");
var html = "";
if (gr.get(current.sys_id)) {
var ga = new GlideRecord('sysapproval_approver');
var app = [];
ga.addQuery('sysapproval', current.sys_id);
ga.query();
while (ga.next()) {
app.push(ga.getDisplayValue('approver'));
}
html += "<h2>RITM Details</h2>";
html += "<b>RITM Number:</b> " + gr.number + "<br/>";
html += "<b>Requested For:</b> " + gr.getDisplayValue('requested_for') + "<br/>";
html += "<b>Requested By:</b> " + gr.getDisplayValue('opened_by') + "<br/>";
html += "<b>Catalog Item:</b> " + gr.getDisplayValue('cat_item') + "<br/>";
html += "<b>State:</b> " + gr.getDisplayValue('state') + "<br/>";
html += "<b>Priority:</b> " + gr.getDisplayValue('priority') + "<br/>";
html += "<b>Assignment Group:</b> " + gr.getDisplayValue('assignment_group') + "<br/>";
html += "<b>Assigned To:</b> " + gr.getDisplayValue('assigned_to') + "<br/>";
html += "<b>Short Description:</b> " + gr.short_description + "<br/>";
html += "<b>Description:</b> " + gr.description + "<br/>";
html += "<b>Approval List:</b> " +
(app.length > 0 ? app.join(', ') : 'No Approvers') +
"<br/>";
html += "<h3>Variables</h3>";
for (var vName in gr.variables) {
if (gr.variables.hasOwnProperty(vName)) {
var question = gr.variables[vName].getQuestion();
var label = question.getLabel();
var value = gr.variables[vName].getDisplayValue();
html += "<b>" + label + ":</b> " + value + "<br/>";
}
}
}
var result = v.convertToPDF(html, "sc_req_item", current.sys_id, "RITM_PDF");
gs.info(JSON.stringify(result));
})(current, previous);
Refer above updated code with variable details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @mr18 ,
I hope your query is resolved . If my response helps you then accept as solution for further future queries.
Regards,
Aditya,
Technical Consultant

