Field Level Scripting in Search Screens

1 minute read time.
Imagine the situation where there may be a problem with allowing users to search against a entity with out putting in at least one search criterion. You may find the searching against companies too slow if people do not put in the company name for example.

If we consider the CompanySearchBox used in the system built company find screen we can try and use the different scripting types to help us.

CreateScript in Search Screens

The onCreate has little help as it is not possible to set the properties of fields in a search screen. For example we may try on the comp_type field to set

Required= true;
DefaultValue = 'Customer';

This will not error but the property settings are just ignored.

Note: Setting the system variable Valid=false; will allow you to write out the contents of the ErrorStr system variable.

onChangeScript in Search Screens

This scripting is passed to the browser and works as in other edit screens. In search screens we can use this (with the custom content field) to implement format masks and other rules to ensure that the data submitted for searching follows the business rules.

Validation on Search Screens

This is most useful and I confess that I rather over looked this behaviour until a partner pointed this out to me.

Validation rules are checked on submission of a search screen even though in this case no data is being inserted or updated. For example the code below on the comp_name will ensure that it can't be left blank when searching for companies.

if (!Values("comp_name"))
{
Valid = false;
ErrorStr = "you must fill in this field";
}
Parents Comment Children
No Data