Skip to main content
Nintex Community Menu Bar
Answer

Print K2 form

  • November 29, 2022
  • 5 replies
  • 142 views

Forum|alt.badge.img+1

I have created a form and I have added a button called "print" so that the form can be printed when clicking. I created a data label with the following expression <script>window.print();</script> and added a transfer data rule to the print button but it did not work. Can someone help me with that please?

 

Thank you!

Best answer by TinTex

Maybe the print() JavaScript executed before Smartforms hide button rule did.

You can try creating an expression, and adding the '<script>window.print();</script>' to that expression. Then clear out your data label but just keep the 'Literal' Property as enabled, and the Prevent XSS as disabled.

Then:

"when button print is clicked
them hide the button print form control

set button print control's properties (set the expression to the one containing '<script>window.print();</script>')"

5 replies

Forum|alt.badge.img+11
  • Nintex Employee
  • November 29, 2022

How was this implemented?

Do you have a data label control where the 'Literal' Property is enabled, and the Prevent XSS is disabled?

Are you setting the data label with the script as the value?

Or do you have the <script>window.print();</script> defined in a expression, and the mapping the expression to the data label with the settings described above?

You can also do a:

when form is initialized

- set property control of the data label described above, setting the expression to the expression with the '<script>window.print();</script>' defined, this may ensure that the print windows will load after the form has fully loaded


Forum|alt.badge.img+1
  • Author
  • Rookie
  • November 30, 2022
A data label is set:
&lt;script type="text/javascript">$(document).ready(function() { $("[title='Action Button']").click(function() {window.print()});});&lt;/script&gt;

It works now. But the "print" button shows when trying to print and I would like to hide it. I created the following rule:

"when button print is clicked
them hide the button print form control "

but it does not work

  • November 30, 2022

There is a data label set:
Text/JavaScript script type="$" (document).
prepared (function() $("[title='Action Button']").
function() "window.print()");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Now it operates. However, I would like to hide the "print" button that appears when trying to print. The following rule was I made:

"When the button print is clicked, the button print form control is hidden."

but it is unsuccessful.


Forum|alt.badge.img+11
  • Nintex Employee
  • Answer
  • November 30, 2022

Maybe the print() JavaScript executed before Smartforms hide button rule did.

You can try creating an expression, and adding the '<script>window.print();</script>' to that expression. Then clear out your data label but just keep the 'Literal' Property as enabled, and the Prevent XSS as disabled.

Then:

"when button print is clicked
them hide the button print form control

set button print control's properties (set the expression to the one containing '<script>window.print();</script>')"


Forum|alt.badge.img+1
  • Author
  • Rookie
  • December 1, 2022
It worked. Thak you!