How can I fetch all the records in a Form that satisfy a given criteria?

How can I fetch all the records in a Form that satisfy a given criteria?

The Count function in Deluge Scripting enables you to get the total number of records in a form satisfying a given criteria. Using the count function, you can check if an entry already exists in a database. 

Deluge Script 

Assume, you have two forms A and B. Form A contains the list of registered members with a valid MemberID, who are eligible to subscribe through Form B. Hence, when a user submits data through Form B, we need to validate to check if the user is already a registered member in Form A. 

This is achieved by writing On Add -> Validate script in Form B, as given below:

if (count(Form_A[MemberID == input.MemberID]) == 0)
{
alert " MemberID is not Found";
cancel submit;
}


Code Explanation

1. The on add -> validate script is executed before submitting the form data in the database.

2. In the following code, the count built-in function will return the number of rows fetched from Form A, with the given criteria:

if (count(Form_A[MemberID == input.MemberID]) == 0)

3. The alert statement is executed if the count function returns 0

alert " MemberID is not Found";

4. cancel submit statement will cancel the record update operation.

cancel submit;

 

    • Related Articles

    • How can I fetch all the records in a Form that satisfy a given criteria?

      The Count function in Deluge Scripting enables you to get the total number of records in a form satisfying a given criteria. Using the count function, you can check if an entry already exists in a database.  Deluge Script  Assume, you have two forms ...
    • How can I fetch records within a given range

      To fetch records from a Form within a given range, specify the start index and end index range in the Fetch records task, as shown in the sample code below. Here, the first five records that are sorted by Added_Time field will be fetched from ...
    • How can I fetch all the records in a form?

      To fetch all the records in a form, specify the criteria as [ID != 0], where ID is a auto-generated field that contains a unique value for each record in the form. Example:  rec = Contact [ID != 0] sort by Added_Time range from 1 to 5; where, rec it ...
    • How can I fetch records from another application

      The Fetch Records statement in Deluge Scripting currently supports fetching data from a form and updating it in another form, within the same application. Fetch and update of data from different applications can be achieved by using Functions. Refer ...
    • Editing Criteria Patterns in Reports

      Edit Criteria Patterns Criteria Pattern Editor in the report help you to define advanced filters using simple logic like and / or. Note You can specify a maximum of 25 criteria in a report. To edit criteria patterns Click the Reports tab. From the ...