Convert submitted RITM with submitted values into PDF and send an email to requestor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:37 AM
Hello all,
I'm trying to convert submitted RITM to PDF and attach that PDF on RITM and send an email to the requestor.
Tried below script It is working with Background script but not with BR, I have written After Insert BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:52 AM
Hi @Meenal Gharat ,
In the below code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:05 AM - edited 06-05-2025 04:45 AM
Hi @Meenal Gharat,
Please try the following lines of code with 2 changes.
var pdfUtil = new sn_pdfgeneratorutils.PDFGenerationAPI;
var fileName = "RITM_"+current.number+"_Details.pdf";
var html = "<html><body>";
html += "<h2>Submitted Request :"+current.number+"</h2>";
html += "<table border ='1 cellpadding ='5' cellspacing='0'>";
html += "<tr><th>Field</th>Value</tr>";
//Get Variables from RITM
var variables = current.variables;
for (var key in variables){
if (variables.hasOwnProperty(key)) // 3rd change
{
var varLabel = variables[key].getLabel();
var varValue = variables[key].getDisplayValue();
html += "<tr><td>"+varLabel+"</td><td>"+varValue+ "</td></tr>";
}
}
html +="</table></body></html>";
var hfInfo = new Object();
//hfInfo["HeaderImageAttachmentId"] = gs.getProperty('sn_cheque_collection_image_id');//sys_id of attachment
hfInfo["PageSize"] = "A4";
hfInfo["GeneratePageNumber"] = "false";
var hfi=new Object();
hfi['PageOrientation']= 'PORTRAIT'; //1st change
hfi["GeneratePageNumber"] = "false";
//hfi["HeaderImageAttachmentId"]=gs.getProperty('sn_cheque_collection_image_id');//sys_id of attachment
var result = pdfUtil.convertToPDFWithHeaderFooter(html, "sc_req_item",current.sys_id, fileName,hfi,'', hfInfo); //2nd change
Regards,
Ehab Pilloor
Edit: Made some corrections after closer inspection, please try and see if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 03:16 AM
Tried the above still no luck.
checked logs it is entering in BR
Is something else we need to check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 04:37 AM - edited 06-05-2025 04:49 AM
@Meenal Gharat, you can disable BR in the script by adding
current.setWorkflow(false); //add after 2nd line
Please note the BR process and see if its relevant in this activity. Also I have made few more corrections in the code posted earlier. Please try and see if it works.
Regards,
Ehab Pilloor