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;