sfCreateDocument

This function is deprecated.

Requests the server to generate a report of a form, usually in PDF format. A PDF report can be generated using a snapshot of the digital form in the browser or a custom report deployed on the server.

When this function is executed in the browser or in the mobile app, it sends a request to the server for the report to be generated. The report is always generated and stored on the server. The generated report can be sent as an attachment in an email to the intended recipients or copied to a standard path from where interfaces can process the document further.

The function can generate more than one reports in one request. In this case, the generated reports are stored as a zip file.

Documents generated using this function can also be downloaded later from the document queue.

Output types

There are two possible output types of a report: PDF or XML.

A PDF report is generated either using a snapshot of the digital form in the browser or a custom report deployed on the server.

An XML report is an XML document that contains the metadata and data of the form.

Syntax

sfCreateDocument (name, type, path, immediateMode)

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

name

string

no

Name of the document to be generated.

If a name is not provided, a default name is assigned by the system in format:

<Form Template Name>_<Current User Display Name>_<DDMMYYYY>_<HHMMSSsss>_<3 Digit Random Number>

type

string

yes

Output type of document to be generated. The type can be either PDF or XML.

path

string

no

Relative path on the server where the generated document should be stored.

If Default_Path is mentioned as the path, the document is stored in the document repository path on the server.

If a relative path is provided along with Server.InterfacePath, the document is stored in the standard path provisioned for interfaces.

If no value is provided, the document is stored in the default path.

immediateMode

boolean

no

Indicates if the document should be generated immediately upon the receipt of the request or can be generated at a scheduled cycle of document generation process.

Usage examples

Example 1

Let us assume a form contains a selectbox control PumpStation, a selectbox control LoadingPump and a date field InspectionDate. To generate a PDF document of the form in the default path,

var reportFileName = sfGetValue('control_pumpstation') + '_' + sfGetValue('control_loadingpump') + '_' + sfGetValue('control_inspectiondate') + '.pdf'; sfCreateDocument(reportFileName, 'PDF');

The PDF document will be created with the file name in format:

<PumpStationCode>_<LoadinPumpCode>_<InspectionDate>.pdf