Creator Help

Add Record

Description

The add record Deluge task is used in Form action and Field action scripts to insert a new record to a given form with values specified in the expression.  

Syntax

The Form definition of the script will be displayed in the Form Definition -> With Action block of the Script Builder, in the format given below. Here, the script is added to the Form Actions - On Add - On Success block of the form.

<ID> = insert into <formname>

[
<fieldname1> = <expression>
<fieldname2> = <expression>
<fieldname3> = <expression>
];

where,

<formname> - name of the form to insert a new record.
<fieldname> - the name of the field in the form
<ID> - ID value of the inserted record
<expression> - the field value or a deluge expression that returns a value

Steps to add the script

To add the add record task in Script Builder,

  1. Invoke the Script Builder and select the Form/Field action.
  2. Drag-n-drop the add record task from the left-side task tree.
  3. Click on Edit to specify the form name, field names and value in the Edit dialog. All the forms in the current application will be listed in the Select Form list-box.
  4. To specify field values, the Deluge expression builder can be invoked for each field by selecting the "Write Expression" button.
  5. Click Done to update the values.

Refer the topic Using Script Builder for steps to add the script.

Example

The sample code given below adds a new record to the expense form based on the values submitted in the payments form. The script is added to the on add -> on success block of the payment form and will be executed when a new record is added to the payment form.

insert into expense
[
Added_User = zoho.loginuser
Amount = input.amount
Category = input.category
Expense_Date = zoho.currentdate
Payment_method = input.pay_method
Description = "Monthly Payments"
]

In the above code,

  • Field name on the left like Added_User, Amount refers to the deluge field names in the expense from
  • Field names on the right with syntac input.<field name> refers to the deluge field names in the payment form.

Related Topics

Sample Application

Top