Dynamic Field Handler
The dynamic field change handler is associated with the dynamic-select field type. This handler is triggered to populate the drop-down menu items for the field based on the user input. The list of menu items to be populated in the drop-down is configured in this handler as a comma separated value list and the search trigger works based on the following criteria:
- starts-with
- contains
Search results are populated based on the starts-with criteria followed by items that match with the contains criteria.
Note: For optimum results configure dynamic_select field only when the search results are more than 100. In case of results lesser than 100, use the select field.
The list of attributes that are passed when this handler is triggered are given below
Attribute name | Description |
operator | Details of the operator who is accessing the widget |
environment | Details of the environment in which SalesIQ has been accessed |
form | Details of the form object and the input values. |
target | Details of the field and the selected input that triggered the change |
Sample Code:
Copiedinfo target;
info form;
countries = {{"name":"Afghanistan","code":"AF"},{"name":"Albania","code":"AL"},{"name":"Algeria","code":"DZ"},{"name":"Antarctica","code":"AQ"},{"name":"Argentina","code":"AR"},{"name":"Australia","code":"AU"},{"name":"Austria","code":"AT"},{"name":"Bahamas","code":"BS"},{"name":"Bangladesh","code":"BD"},{"name":"Belgium","code":"BE"},{"name":"Bhutan","code":"BT"},{"name":"Brazil","code":"BR"},{"name":"Bulgaria","code":"BG"},{"name":"Cambodia","code":"KH"},{"name":"Cameroon","code":"CM"},{"name":"Canada","code":"CA"},{"name":"Chile","code":"CL"},{"name":"China","code":"CN"},{"name":"Congo","code":"CG"},{"name":"Costa Rica","code":"CR"},{"name":"Cuba","code":"CU"},{"name":"Denmark","code":"DK"},{"name":"Egypt","code":"EG"},{"name":"Finland","code":"FI"},{"name":"France","code":"FR"},{"name":"Georgia","code":"GE"},{"name":"Germany","code":"DE"},{"name":"Greece","code":"GR"},{"name":"Greenland","code":"GL"},{"name":"Hong Kong","code":"HK"},{"name":"Hungary","code":"HU"},{"name":"Iceland","code":"IS"},{"name":"India","code":"IN"},{"name":"Indonesia","code":"ID"},{"name":"Iran, Islamic Republic Of","code":"IR"},{"name":"Iraq","code":"IQ"},{"name":"Ireland","code":"IE"},{"name":"Isle of Man","code":"IM"},{"name":"Israel","code":"IL"},{"name":"Italy","code":"IT"},{"name":"Jamaica","code":"JM"},{"name":"Japan","code":"JP"},{"name":"Kuwait","code":"KW"},{"name":"Malaysia","code":"MY"},{"name":"Mexico","code":"MX"},{"name":"Nepal","code":"NP"},{"name":"Netherlands","code":"NL"},{"name":"New Zealand","code":"NZ"},{"name":"Pakistan","code":"PK"},{"name":"Philippines","code":"PH"},{"name":"Poland","code":"PL"},{"name":"Portugal","code":"PT"},{"name":"Singapore","code":"SG"},{"name":"Slovakia","code":"SK"},{"name":"Slovenia","code":"SI"},{"name":"Sri Lanka","code":"LK"},{"name":"Sweden","code":"SE"},{"name":"Switzerland","code":"CH"},{"name":"Turkey","code":"TR"},{"name":"United Arab Emirates","code":"AE"},{"name":"United Kingdom","code":"GB"},{"name":"United States","code":"US"},{"name":"United States Minor Outlying Islands","code":"UM"},{"name":"Yemen","code":"YE"},{"name":"Zimbabwe","code":"ZW"}};
fieldName = target.get("country");
query = target.get("query");
countriesList = List();
count = 0;
for each country in countries
{
countryName = country.get("name");
if(countryName.containsIgnoreCase(query))
{
code = country.get("code");
Country = {"label":countryName,"value":code};
if(count < 8)
{
countriesList.add(Country);
}
count = count + 1;
}
}
return {"options":countriesList};