Would like to use PDF Generator Preview PDF UI Action in Agent Workspace

kmolson73
Tera Expert

We have implemented the stand alone PDF Generator application and have been using it for quite some time with our custom applications and it works great. We are now trying to see if it would be possible to use it within the Agent Workspace. I have successfully been able to get the Preview PDF ui action to show on the workspace in our records there but when I click it nothing happens. Has anyone tried this before? I'm assuming that we will need to adjust the script but am not sure where to start. We are able to open existing PDF's in the workspace with no problem, but are not able to create a preview. Below is a sample of our UI action workspace client script: 

function onClick(g_form) {

setLetterDate();

var ques_mod = "This form has been modified and must be saved before generating documents. Press OK to save.";

if (g_form.modified) {
if (confirm(ques_mod)) {
g_form.save();
return false;
} else return false;
}

function setLetterDate() {
var d = new Date();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
var day = d.getUTCDate();
var year = d.getUTCFullYear();
g_form.setValue('letter_date', n + " " + day + "," + " " + year);
}


var sysId = typeof rowSysId == 'undefined' || rowSysId == null ?
gel('sys_uniqueValue').value : rowSysId;


var dialog = new GlideModal('Preview document dialog v2');
var msg = new GwtMessage().getMessage('Edit document');

dialog.setTitle(msg);
dialog.setPreference('sysparm_sysId', sysId);
dialog.setPreference('sysparm_sourceTable', g_form.getTableName());
dialog.setPreference('sysparm_templateTable', 'u_general_document_template');
dialog.setPreference('sysparm_templateName', g_form.getValue('document_type'));
dialog.setPreference('sysparm_fileName', (g_form.getValue('number') + ': ' + g_form.getValue('document_type')));
dialog.setPreference('sysparm_editableTemplate', 'false');
dialog.render();
}

2 REPLIES 2

Sandhya Bellann
ServiceNow Employee
ServiceNow Employee

Refer https://support.servicenow.com/kb?id=kb_article_view_popup&sysparm_article=KB0743790 to see if it can help

Thank you Sandhya, I will look into this.