When the user clicks on the select icon of a capture field (uitype 10) a popup screen appears with the list of records of the module being selected. In certain situations it is necessary to pre filter the results for the user
In fact the application already does this in various parts, for example when selecting a contact after having selected an account on an invoice. Only the list of contacts related to the account will appear.
This tutorial will teach you how to implement such a feature for your uitype10/capture fields.
What we need to do to get this working is inform the popup code to launch a search on the set of records to return. This functionality already exists in the popup code, so we don't need to add any code there, we just have to pass in the right parameters to let the popup code know that it has to setup a conditional query instead of a full query.
The three parameters the popup code expects to see in order to setup a conditional query are:
if searchtype=BasicSearch then we have to send in these additional variables:
if searchtype=advance then we have to send in this additional variable:
where the json object has this format:
{ "groupid":"number that identifies the group of conditions", "columnname":"coreBOS advanced column identifier" "comparator":"comparison operator" "value":"text to look" "columncondition":"and|or" (logical operator to join with the next condition) }
the coreBOS advanced column identifier has this format:
table_name:field_name:column_name:label:data_type
for example
vtiger_account:accountname:accountname:Accounts_Account_Name:V
the comparison operator can be
Note that this JSON object is much more complex than is shown here supporting not only various fields but also different groupings of conditions. If you need a complex condition I would recommend creating a filter with the condition. On the filter there is a nice editor that will permit you to add the fields, conditions and different groupings. Then simply capture the save event to see how coreBOS creates the JSON object and use that.
Now that we know what we have to do, let's see some examples.