Automatically print Dynaform when submitting

From pmusers
Jump to: navigation, search

This example shows how to automatically print a Dynaform when the Dynaform is submitted.


Dynaform: Automatically print when submitting.json (right click and select Save Link As)
Author: Amos Batto <amos[at]processmaker.com>
Version: 1.0 (2019-05-06)
Tested in: PM 3.3.4 Enterprise in Debian 9.5 with Firefox 60.5


In the Dynaform properties, mark the option print dynaform:

MarkPrintDynaformOption.json

Then, add the following JavaScript to the Dynaform:

$("a.print-button").hide(); //comment out if not wishing to hide the print icon

var printed = false;
getFormById( $("form").prop("id") ).setOnSubmit( function() {
  if (printed == false) {
     $("a.print-button").click();
     printed = true;
     return false;
  }
});

The first time the Dynaform is submitted, it will automatically open the system's dialog box to print the Dynaform. It also stops the submit action, because the Dynaform can't be printed after it is submitted.

SystemPrintDialog.png

The second time the user tries to submit the Dynaform, it will be allowed to submit normally and the process will continue.