Hello SharePointers,
Today we are going to see How to add Print button in Nintex Form. In Nintex Forms – Add Quick and Easy Print Function is very easy. To do that just follow below steps.
Nintex Forms – Add Quick and Easy Print Function
This JavaScript allows you to quickly and simply print the form and fields including formatting.
Instructions to Add Print Function in Nintex Form
- Edit the form
- Add a Button
- Change the button type to “JavaScript”
- Set JS function to “PrintRequest()” (minus double quotes)
- Edit Form Settings
- Add the following JS to the Javascript Section
function PrintRequest(){
var formInfo = document.getElementById("ctl00_ctl67_g_daea14f1_4135_4ea3_a9fc_fbe9bfbf182e_ctl00_ListForm1_MiddleDiv").innerHTML;
var htmlBody = "<!DOCTYPE html>" +
"<html>" +
"<head>" +
"<title>Lab Request</title>" +
/*"<title>" + getTextBoxFieldValue(".cssTitle", txtTitle) + "</title>" + */
"<link rel='stylesheet' href='https://one.belden.com/_layouts/15/1033/styles/Themable/corev15.css?rev=WBDzE8Kp2NMrldHsGGXlEQ%3D%3D'>" +
"<link rel='stylesheet' href='https://one.belden.com/_layouts/15/NintexForms/themes/base/Filler.css?v=2.11.8.30'>" +
"<style>body{overflow: auto !important; margin:0px; padding:0px; font-family:Tahoma,Helvetica,Arial,sans-serif; font-size:13px; background-color:white;}.nf-button{visibility:hidden;}</style>" +
"</head>" +
"<body>" +
"<div id='mainDiv'>" +
formInfo +
"</div>"+
"</body>"+
"</html>";
Print(htmlBody);
}
function Print(htmlBody){
var xMax = 1024, yMax = 768;
if (document.all) {xMax = screen.width; yMax = screen.height;}
else if (document.layers) {xMax = window.outerWidth; yMax = window.outerHeight;}
var WindowObject = window.open('', '', 'width=' + xMax + ',height=' + yMax + ',toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.write(htmlBody);
WindowObject.document.close();
WindowObject.focus();
setTimeout(() => { WindowObject.print(); }, 1000);
}
7. Add rule to the button to disable onnew & onedit
8. Publish it
By this way you can add a Print button in Nintex Forms.
Hope you like this article, If yes, then please share your feedback in comments.
You may also like our other posts.
- SPFx Interview Questions
- PnP PowerShell to get all Site Collections
- Check date field is empty in Nintex Workflow
Nintex Form – Add Print Button