Add Record Using Add Record Task in Sample Application

Table of Contents

About the application

Let us take the example of the Expense Tracker application in the Market Place to illustrate the usage of the Add Record task. In the Demo version, select Reports -> UpdateMonthly Payments. This view displays the fixed monthly expenses to be made on a specific day of each month. Each record displays the Add to expense custom action button. When a monthly expense is paid, the user can automatically update this expense to his Expense form, by selecting the custom action button.

The Add to expense button internally invokes the AddToExpense function which adds a new record to the Expense Form, based on the specified values. Now let us learn how the custom action button Add to expense is added to the above view.

Steps to configure the custom action button

"Custom Action" is a feature integrated in ZC Views to enable users to invoke a specific user-defined Function on selected records in a view. In this application, "Add to expense" custom action button invokes the function that will add a new record to the Expense Form, based on the specified values.

a. Defining the Function to add a new record

Select Workflow -> Function tab and define a new function by selecting the New button.

In the Function dialog, specify the function name, namespace, return type and arguments to be passed to this function. In this example, we define a function named "AddToExpense" that will add a new record to the Expense Form, based on the specified values. The following arguments are defined in the function:

"num" of type float to specify the expense amount

"cat" of type string to specify the expense category

"sub" of type string to specify the expense sub-category

"monthly-pay-method" of type string to specify the payment method.

Click Done to add the function. The function "AddToExpense" is added to the editor area as shown in the screen-shot given below:

Now, let us add the tasks to be performed by this function. Drag-n-drop the add Record deluge task to the editor-area and click on the Edit option to configure the Form name and the record values. In this application, the record is added to the "add_new_expense1" form. The record will be added with the values passed by the function arguments.

Click Save Script to update the changes.

b. Configuring the function as Custom Action in the View

To configure the function as a custom action in the view,

Select the required report and click on Custom Actions from the left-side tree. In this application, we will select the View Update Monthly Payments.

Specify the Action Name, the action display type,the function to be configured and the argument values. Here, the field values of the Update Monthly Records view will be passed as argument values.

Click Done to update the changes.The custom action configured for the selected view will be displayed as shown in the screen-shot given below:

The above configuration will add the Add to expense custom action button to each record in the Update Monthly Records View. When the button is clicked, a new record is added to the Expense Form, with the specified values.