sfAddSystemTriggerAction

Requests the server for a system action like send an email or create a report.

This function is for advanced customization of system action requests. For simpler implementations, refer to

  • sfCreateDocument - to generate a report of a form, usually in PDF format

  • sfSendEmail - to send an email, optionally along with a print document of a form

When this function is executed in the browser or in the mobile app, it sends a request to the server for the system action to be executed. The action is always executed on the server (and never directly from the browser or the mobile app).

Syntax

sfAddSystemTriggerAction (action, actionParameters, immediateMode)

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

action

string

yes

Name of the system action to be executed.

  • SEND_EMAIL requests an email to be sent out.

  • CREATE_DOCUMENT requests a report to be created.

actionParameters

json

yes

Parameters required to execute the requested system action. The parameters are different for each action. Click here for the parameters supported for each action.

immediateMode

boolean

yes

Indicates if the system action should be request immediately or wait until the user saves the current form.

actionParameters

Each system action requires a set of action parameters to correctly execute the request. The parameters supported for each different.

SEND_EMAIL

Signature

sfAddSystemTriggerAction("SEND_EMAIL", "{ 'emailTemplateName': '', 'emailAttributes': { 'nameFrom': '', 'emailAddressFrom': '', 'emailAddressTo': '', 'emailAddressCc': '', 'emailAddressBcc': '', 'subject': '', 'emailBody': '' }, 'attachments': [{ 'type': 'FORM_DOCUMENT', 'name': '', 'formId' : 'uniqueidentifier', 'path': 'Default_Path;Server.InterfacePath', 'reportName': '', 'params': { 'paramName': 'paramValue' } },{ 'type': 'FORM_FILES', 'formId' : 'uniqueidentifier', 'expression': '.*pdf$' }], 'referenceFormId': 'uniqueidentifier', 'execution': 'IMMEDIATE/BATCH', 'runtimeReference': '' }", true/false);

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

emailTemplateName

string

no

Name of the email template that contains the email configuration like the recipients, email subject and email body.

It is optional if all required email configuration is sent as emailAttributes.

emailAttributes

json

no

Email configuration details for the email to be sent out.

  • nameFrom: Name of the sender as it should be displayed in the email.

  • emailAddressFrom: Email address of the sender to be used when sending the email. If the recipients reply to the email, the reply will be received at this email address.

  • emailAddressTo: Email address of the recipient. Multiple email addresses can be added separated by comma.

  • emailAddressCc: Email address to whom a copy of the email should be sent out. Multiple email addresses can be added separated by comma.

  • emailAddressBcc: Email address to whom a blind carbon copy of the email should be sent out. Multiple email addresses can be added separated by comma. Use blind carbon copy when the other recipients of the email should not be notified that the email has also been sent to this recipient.

  • subject: Subject of the email.

  • emailBody: Content of the email.

If an email template is not used (i.e. emailTemplateName is skipped), then at least the sender name, sender email, subject, body and at least one recipient must be mentioned in emailAttributes.

If an email template is mentioned along with the email attributes, then the attribute provided in emailAttributes is preferred over the conflicting attribute in the mentioned email template.

If the sender email address does not belong to smartflowcloud.com domain, the server may reject the emails. Contact the support team to verify if the desired domain is supported.

attachments

json

no

Details of the attachments to be included in the email.

To attach a report file,

  • type: Must be FORM_DOCUMENT.

  • name: Name to be used for the generated report file. 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>

  • formId: Identifier of the form the report should be generated from.
    By default, the form that triggered the email request is used as reference.

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

    • Default_Path: Stores the document in the standard document repository path on the server.

    • Server.InterfacePath: Stores the document in the standard path provisioned for interfaces. Usually a relative path is provided along with Server.InterfacePath.

      If no value is provided, the document is stored in the default path.
      If a document should be stored in multiple copies at different locations, multiple paths can be provided separated by a semi-colon.

  • reportName: In case of RDL reports, name of the RDL report to be used to generate the PDF.

  • params: Key-Value pairs of parameters to be sent to the document generation process.

To attach the form files,

  • type: Must be FORM_FILES.

  • formId: Identifier of the form the report should be generated from. If no identifier is mentioned, the current form in the context is considered.

  • expression: Regular expression to filter the form files that should be included as attachments.

referenceFormId

guid

no

Form reference to be used to fetch data for placeholders in the email attributes and body.

By default, the form that triggered the email request is used as reference.

execution

string

no

IMMEDIATE/BATCH

runtimeReference

string

no

 

Usage examples

To send an email using email template OperationalAgreement_Completed along with the print of the form using report template OperationAgreementPrint as attachment,

sfAddSystemTriggerAction("SEND_EMAIL", "{ 'emailTemplateName': 'OperationalAgreement_Completed', 'attachments': [{ 'type': 'FORM_DOCUMENT' }] }", true/false);

To pass runtime parameters to be used during print generation,

sfAddSystemTriggerAction("SEND_EMAIL", "{ 'emailTemplateName': 'OperationalAgreement_Completed', 'attachments': [{ 'type': 'FORM_DOCUMENT', 'params': { 'SummaryOverview': 'show' } }] }", true/false);

To use a different print format (report template) OperationAgreementPrint instead of the default print format configured for the form,

To use a different recipient and subject instead of the ones defined in the email template,

CREATE_DOCUMENT

Signature

Parameters

Name

Type

Mandatory

Description

Name

Type

Mandatory

Description

name

string

no

Name to be used for the generated report file. 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>

formId

json

no

Identifier of the form the report should be generated from.

If no identifier is mentioned, the current form in the context is considered.

path

string

no

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

  • Default_Path: Stores the document in the standard document repository path on the server.

  • Server.InterfacePath: Stores the document in the standard path provisioned for interfaces. Usually a relative path is provided along with Server.InterfacePath.

If no value is provided, the document is stored in the default path.
If a document should be stored in multiple copies at different locations, multiple paths can be provided separated by a semi-colon.

type

string

yes

PDF/XML

reportName

string

no

In case of RDL reports, name of the RDL report to be used to generate the PDF.

params

json

no

Key-Value pairs of parameters to be sent to the document generation process.

referenceFormId

guid

no

Form reference to be used to fetch data for placeholders in the email attributes and body.

By default, the form that triggered the email request is used as reference.

execution

string

no

IMMEDIATE/BATCH

runtimeReference

string

no

 

Usage examples