===== Autocomplete ===== Autocomplete functionality is so typical for a backend that coreBOS had to have this functionality natively. We have two methods that permit us to easily implement this functionality. ==== Methods ==== ^Method:|getFieldAutocomplete| ^Purpose:|Executes a search in the list of fields of a module for the given term with the selected operator.| ^Profile:|getFieldAutocomplete(term:string, filter:string, searchinmodule:string, fields:string, returnfields:string, limit:number):Map| ^Send as:|GET| ^Parameters:| => term: search term \\ => filter: operator to use: eq, neq, startswith, endswith, contains \\ => searchinmodule: valid module to search in \\ => fields: comma-separated list of fields to search in \\ => returnfields: comma-separated list of fields to return as result, if empty fields will be returned \\ => limit: maximum number of values to return| ^Response:|Map of records found, indexed by their CRMID with the value of a Map of the returnfields fields| ^Example:|[[https://github.com/tsolucio/coreBOSwsDevelopment/blob/master/testcode/334_getFieldAutocomplete.php|Developer Tool]]| ^Method:|getReferenceAutocomplete| ^Purpose:|Executes a search in the entity fields of the given modules for the given term with the selected operator.| ^Profile:|getReferenceAutocomplete(term:string, filter:string, searchinmodules:string, limit:number):Map| ^Send as:|GET| ^Parameters:| => term: search term \\ => filter: operator to use: eq, neq, startswith, endswith, contains \\ => searchinmodules: comma-separated list of modules to search in \\ => limit: maximum number of values to return| ^Response:|Array of records found with three values for each one: \\ => crmid: ID of the record \\ => crmname: entity name of the module followed by the module name \\ => crmmodule: module the record belongs to| ^Example:|[[https://github.com/tsolucio/coreBOSwsDevelopment/blob/master/testcode/334_getReferenceAutocomplete.php|Developer Tool]]| ==== Autocomplete Example ==== This section explains how to implement an autocomplete dropdown and selection UI using the coreBOS web service API. Let’s go over the important points of the next code which implements the autocomplete
- We load the javascript promise based library, create the necessary HTML and connect to our coreBOS from line 1 to line 37. - recordTemplate is just to fill in the drop-down with the values returned from the call - getRecords is the operative function that sends the search term to coreBOS method **getReferenceAutocomplete** with the correct parameters to search in the Accounts and Contacts module. - doSearch triggers when the user types in the characters, makes the call and loads the results ---- [[:en:devel:corebosws:getrelatedrecords|Next: Get Related Records method]] | [[en:devel:corebosws:tableofcontents|Table of Contents]] ----