Creator Help

Buffet Menu

The Buffet Menu application comprises of a Menu form with multi-select fields that list the menu items in each food category.

 Selection of the food items for the buffet is subject to the following restrictions:

  • Only a total of ten items can be chosen from the different categories.
  • A minimum of one item must be selected from each category.
  • Only three premium items can be included.

Deluge Scripts added to the application

1. Validate script 

When the Menu form is submitted, the validate script is executed to validate the form data for the above said conditions. Script is added to the Menu form - Actions - On Add - On Validate section.  List functions are used to validate the data. The scripts for the 3 conditions are explained below:

a. Only a total of ten items can be chosen from the different categories

In the following code, the If condition sums up the number of items in each list using the <list>.size() funtion. If the total items selected exceeds 10, an alert message is displayed and the submission is canceled. 


if ((input.Main_course.size() + input.Starters.size()+input.Desert.size()+input.Soups.size())>10)
{
alert "Altogether only 10 items can be selected";
cancel submit;
} 

 

b. A minimum of one item must be selected from each category

In the following code, the If condition checks it at least one item is added in each category using the <list>.size()funtion. If not, an alert message is displayed and the submission is canceled.


if ((((input.Main_course.size() <1) || (input.Starters.size() <1)) || (input.Desert.size() <1)) 
|| (input.Soups.size() <1))
{
alert "Atleast one item must be selected from each category";
cancel submit;
}

 

c. Only three premium items can be included

In the following code,

    • A new list named totalList is created.
    • The <list>.addall deluge task adds the elements in the given list to the totallist.
    • Each element in totallist is iterated to check for the total number of premium items ordered. If the premium items exceed 3, an alert message is displayed and the submission is cancelled.

totalList = List();
totalList.addall(input.Main_course);
totalList.addall(input.Starters);
totalList.addall(input.Desert);
totalList.addall(input.Soups);
noOfPremium = 0;
for each elem in totalList
{
if (elem.contains("-- Premium"))
{
noOfPremium = (noOfPremium + 1);
}
}
if (noOfPremium >3)
{
alert "Only three premium items are allowed";
cancel submit;
}

2. On user input script

The on user input script is executed when you select/change the value of a field in your form. The script calculates the total number of items selected and displays it in a Note field. This script is added to all the multi-select list fields.


Desert
(
type = list
values = {"Italian delight (Cake)", "Chocolate Opera (Cake)", "Ambrosian delight (Ice Cream)", 
"Jumbo delight (Ice Cream)", "Pista Pasta (Ice Cream) -- Premium"}
on user input
{
input.plain1 = ("<b><ul>No of items selected:" + ((input.Main_course.size() 
+ input.Starters.size() + input.Desert.size() + input.Soups.size()))) 
+ "</ul></b>";
}

To install the application, 

Learn how to install the application to your account - click here.

Top