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.
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>
<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
To add the add record task in Script Builder,
- Invoke the Script Builder and select the Form/Field action.
- Drag-n-drop the add record task from the left-side task tree.
- 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.
- To specify field values, the Deluge expression builder can be invoked for each field by selecting the "Write Expression" button.
- Click Done to update the values.
Refer the topic Using Script Builder for steps to add the script.
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.