Update Records

Update Records

Table of Contents​

Overview

In the previous topic, Fetch Records we learnt how to retrieve the Form data and store it in a form variable. This form variable, also called collection variable, contains the retrieved form data. You can update the retrieved data by accessing the required field values through the form variable.

Syntax

<formvariable>.fieldname = <expression>

where,

  • formvariable - it is the name of the collection variable that contains form data. Read More
  • fieldname - name of the field to be updated
  • expression - any valid deluge expression that evaluates to a value

If you are updating the value of the current form record being submitted, you need not explicitly fetch them. You can directly use the fieldname for updating as given below:

fieldname = <expression>

where,

  • fieldname - name of the field to be updated
  • expression - any valid deluge expression that evalutes to a value.

Sample App

You can fetch and update records from a form using Deluge script. Let us illustrate this with the help of an example.The application Library Manager has three forms:

Books – To enter the details about each book with fields Name, Status and Author. The column ‘Status’ with values ‘Available’ and ‘Issued’, indicates whether the book is available in the library or is issued to any user.

Issue Book – To enter the details about the books issued. This form has a lookup field “Book Name” which imports the Books from the above form. Only the Books whose status is “Available” is listed in the lookup field. This is achieved by specifying the criteria Status==”Achieved”, while creating the lookup field. When a Book is issued, the status of the Book is updated from “Available” to “Issued” in the Books form.

In the Books form, the Status of these books will be set to “Issued”. The following script is written to fetch specific records from the Book form with Name same as the currently submitted book name. The record fetched is stored in the collection variable named myBook. You can now access any field in this record, from the myBook variable and update the value. Here, we have updated the Status field with value as "Issued".

Code Explanation

MyBook = Books [Name == input.Book_Name];

Fetch records from Books form with the given criteria and store it in collection variable named “MyBook”

MyBook.Status = “Issued”;

Access the Mybook variable and update the Status field with value “Issued”.

The books issued is now updated with Status as “Issued” in the Books form.

Return Book

This form is used to enter the details about the books returned. This form has a lookup field “Book Name” which imports the Books from the Books form. The books whose status is “Issued” is listed in the lookup field. This is achieved by specifying the criteria Status ==”Issued”, while creating the lookup field.

When a Book is returned, the status of the Book is updated from “Issued” to “Available” in the Books form. In the Books form, the Status of these books will be set to “Available”. This is achieved using the following script:

Code Explanation:
MyBook = Books [Name == input.Book_Name];

The above code is used to fetch records from Books form with the given criteria and store it in collection variable named “MyBook”.

MyBook.Status = “Available”;

The above script is used to access the Mybook variable and update the Status field with value “Available”.

The books issued is now updated with Status as “Available” in the Books form.

To install the application,

  1. Download the script file (.ds file)
  2. Install the application to your account

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com