Mandatory form fields
In online forms it is pretty common to use mandatory fields which must be filled in before the form can be sent.
This functionality can be provided in todo4teams, too - and this in a variety of elaborated manners:
- login to todo4teams as administrator or superadministrator
- switch to the tab "Forms"
- Select the form for that you want to define mandatory form fields
- Go to "Edit"
- Switch to the tab "send action"
This script-action will be executed as soon as the user applies this form und tries to send the ticket.
if(name.length()==0){
helper.errorMessage("Please enter a name!");
result="error";
}
The script now determines the entry in the "Name" field. If there is no existing value (ie name.length()==0) an error message will be generated through the helper.errorMessage method and further processing of the ticket is stopped by the allocation result="error".
The user then has the opportunity to complete his entries and try again.
You can go one step further, connecting several fields with dependencies:
If you for example provide the fields "postal code" and "city", you can define that the city location must always include a specified postal code, but on the other hand both fields may remain blank.
The corresponding script may look like:
var zipcode = form.getValueByFieldName("ZipCode");
if(city.length()>0 && zipcode.length()==0){
helper.errorMessage("Please enter the zip code!");
result="error";
} else if(city.length()==0 && zipcode.length()>0){
helper.errorMessage("Please enter the city!");
result="error";
}