Field Lookup Handler

Field Lookup Handler

Overview

The field lookup handler can be used to fetch values for field options from external services in real-time. The two main instances are as follows:
  1. The field may require updated options from external services in real-time. In such cases, the data can be fetched using the field lookup handler instead of overloading the menu click handler or form change handler.
  2. The field may have more than 3000 options which is higher than the allowed limit. Therefore, instead of loading all the options in a single call, the developer can lookup/search the options in external services based on the query given by the user in real-time 

How to enable the field lookup handler?

Set the value of the lookup attribute in the required field object as true. And set a value for the triggerLength attribute to define the number of input characters after which the field lookup handler should be triggered.

When is the field lookup handler executed?

The field lookup handler is executed when the user starts typing the search string in the field. The menu developer can also set a minimum limit to the query string. This ensures the field lookup hander is triggered only when the user enters the required number of characters in the input field. 

Implementation of field lookup handler

The information will be passed through the following parameters to the field lookup handler.
 
form
Input collected from the user
user
Details of the user executing the menu.
entity
Details of the entity in which the menu is being used.
target
Field details which have been searched for more options
network
Details of the network in which the menu is being executed.
 
 
Attributes of Field Lookup Handler's response
 
Attribute
Property
Description
options
JSONArray
Maximum Size - 1000
The new array of options that has to be added to that field.
info
String (250)
The message that has to be displayed when the handler could not fetch the results matching the user input.
lookup
Available choices:  true/false
Default value:  True
When the required results have been fetched, the lookup property of the field can be changed to avoid further unnecessary lookups.
Table 1
 
The code shows how to update the options in a multiSelect field and disable the further lookups. 

{ "lookup":false,

"options":[

{

"id":"4000000009065",

"label":"Zoho Payments"

},

{

"id":"4000000009079",

"label":"Zoho Projects"

}

] }

The code given below is to display an information/blank state message when the handler could not fetch the results matching the user input:

{

      "info":"Please try again after some time." }
Result:




The field lookup handler will not be executed in the following cases:
  1. The field object's lookup value is set to be true, but the field lookup handler is not implemented.
  2. The field lookup handler is implemented, but the field object's lookup value is set to be false.