We build systems that integrate with your existing applications & processes to solve complex problems.
Replace redundant manual processing of tasks with AI powered Automation, Robotic Process Automation & Workflow Automation.
Make Intelligent business decisions through smart Dashboards. Visualise, Organise & Forecast your Data!
Many a times, when you are developing an application, you may need to get the value(s) entered for the fields in the form. To get the particular value, you can do so in Deluge Script, using the statement:
input.<Field Name>
For ex, if you would like to obtain the value entered for the field with Field Name “Age”, you can to write
input.Age
For Multi-select and Checkbox fields, the above statement will return a collection and you’d need to iterate the collection and get each one of the selected values. You can use for each element task under List manipulation in the Script Builder for the same.
for each <elementname>
in <listname>
{
// write your code here
}
For ex, if you would like to get the values selected for a multi-select field with Field Name “Hobbies”, you need to write
for each selectedValue
in input.Hobbies
{
alert(selectedValue
);
}
A Note field is used to display text or images that guide the user while filling the form. This field will not be displayed in the View. You can display custom error messages in the Note field based on user input, using Deluge Scripting. The sample application Update Note demonstrates how to display customized text in a Note field, based on user input to your form.. The script modifies the content of a Note field when a client-side event happens.
The application comprises of a form named Test form with the following fields:
1. When the form is loaded, the on add -> on load script hides the note_buffer field, using the hide syntax.
on add
{
on load
{
hide note_buffer;
}
}
2. The on user input script added in the Fruit field updates the note_buffer with a blob of HTML as a multiline string, based on the Fruitselected. This is then displayed in the the_note field.
Fruit
(
type = picklist
values = {"apple", "banana", "cantelope"}
on user input
{
if (input.Fruit == "apple")
{
input.note_buffer = "<img height='250' width='250' src='http://images.jupiterimages.com/common/detail/39/61/23036139.jpg'/>";
}
else if (input.Fruit == "banana")
{
input.note_buffer = "<img height='250' width='250' src='http://www.momadvice.com/blog/uploaded_images/banana-759611.jpg'/>";
}
else if (input.Fruit == "cantelope")
{
input.note_buffer = "<img height='250' width='250' src='http://www.kids-cooking-activities.com/images/cantelope.jpg'/>";
}
input.the_note = input.note_buffer;
}
)
Code Explanation
if (input.Fruit == “apple”) – If condition to check the Fruit type
input.note_buffer = “<img height=’250′ width=’250′ src=’http://images.jupiterimages.com/common/detail/39/61/23036139.jpg’/>”; – Stores the html code as a multi-line string in the note_buffer field.
input.the_note = input.note_buffer; – Updates the_note field with the value stored in the above note_buffer field. This field displays the actual image.
3. If the show_monkey checkbox is selected, the on user input script added in the show_monkey field updates the note field with the fruit type and the monkey image, else only the fruit type is displayed.
show_monkey
(
displayname = "Flash monkey?"
type = checkbox
defaultvalue = false
on user input
{
if (input.show_monkey)
{
input.the_note = input.note_buffer + "<img height='250' width='250' src='http://upload.wikimedia.org/wikipedia/commons/2/27/Baby_ginger_monkey.jpg' />";
input.show_monkey = false;
}
else
{
input.the_note = input.note_buffer;
}
}
)
To convert the date format from “DD-MMM-YYYY” to “YYYY-MM-DD”, change the string with first format to date. Then convert that date object to a string specifying the second format. The below is the sample function which converts the format of the date to “YYYY-MM-DD” and return it as a string. Please refer to it.
The method of filtering a multi-select field is very similar to dynamically filtering single-select dropdowns as described here. However, the problem with filtering a multiselect is that when you edit the record the filtered list is not shown and all the checkbox options given in edit mode are listed instead. Filtering it again causes the selected options for the record to be lost. The workaround is to add a script in the on Edit>on Load task that saves the selected options, filters the list and sets the selection back again.
1. Create the multiselect with dummy options, note that when selections are saved in the field those options will be saved automatically
2. Setup dynamic filtering in the same way as for dropdown fields
3. In the on Add>on Edit action of the form write the following code:
//first save the checked options in the Course field
x = List();
for each opt in input.Courses
{
x.add(opt);
}
//clear it and filter it so that it shows the correct courses for the selected School
clear Courses;
rec = CourseForm [Criteria == input.School];
Courses:ui.add(rec.Courses.getall());
//set the previously selected options again
for each y in x
{
Courses.select(y);
}
To get the Deluge name of a field from the Form,
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 two forms:
Books – To enter the details about each book with fields Name, Status and Author. The following books are owned by the library. 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. For example, the following books are issued.
In the Books form, the Status of these books will be set to “Issued”. This is achieved using the “Issue _Book -> on add -> on success” script, given below:
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, as shown in the screen-shot below:
The for each syntax in Deluge scripting, enables you to conditionally fetch a collection of records and iterate over them. Let us illustrate this with the help of a simple example. The CEO of a company wants to address all the new employees who have joined after certain date say, ’10-jun-2007′ . We have to mail all these new employees. Lets see how we can achieve this.
1. Form ‘Employee’ has the following fields: Name, Qualification, EmailID, TeamName, JoinDate
2. Write Form Actions -> on add -> On success script, as given below:
for each x in Employee [JoinDate > '10-Jul-2007']
{
sendmail
(
To : x.EmailID
From : "yourmail@yourdomain.com"
Subject : "Meeting at 6:pm tomorrow"
Message : "As our CEO wants to address the new employees, you are requested to attend the meeting.<br>Thanks"
)
}
Code Explanation
for each x in Employee [JoinDate > '10-Jul-2007'] -
Fetch the records from the Employee form with the given criteria and iterate over each record, to send mail to the EmailID of each record. Here ‘x’ is the instance variable that will represent a single record in each iteration.
sendmail
– The deluge function to send mail
x.EmailID
– Refers to the emailid of each record
Riko Solutions acknowledge the Aboriginal and Torres Strait Islander peoples as the true custodians of the land in which we live and work.