Edit

DoForm (formName, format, search [, parameters, ...])

Result Type:  a path string

Definition:  Generates a pdf file containing custom form output.

Format will usually be "pdf". The return value in this case is the path to a temporary file that will be deleted when you quit.

From MoneyWorks 8.0, the format may also be "preview", in which case the output will be displayed in the preview window. If you intend previewed statement forms to be emailed, you can supply an integer parameter named contactRole with bit(s) set for the contact(s) whose addresses you want to encode in the Preview for subsequent emailing.

From MoneyWorks 9.1.1, the return value will begin with "[ERROR]" if the operation failed. Previously a failure (such as formName specifying a non-existent form) would result in an empty PDF file.

Also, from MoneyWorks 9.1.1, the search expression can access the in-scope variables of the calling handler, so can e.g. reference a selection variable: "[transaction:mySel]" or ordinary variable "ourref=myRefStr"

Parameters (for the form) should be strings in the form "paramName=paramValue". An associative array is also acceptable. If the form makes use of an ephemeral system variable such as MESSAGE (which is set only when the Print Invoice command is used), you must set a value for those variables in the parameters (because if no invoice has yet been printed in the session, MESSAGE will not yet exist).

Example: 

let path = DoForm("Product Invoice 1", "pdf", "sequencenumber=992", "message=", "print_copy=0")

If multiple records are selected, all output still goes to the same PDF.

Availability:  MWScript handlers. This function is closely analogous to the command line and REST doform commands.