1 var REST = library.REST.REST(); 2 3 /** 4 * Pushes the suggestions into the output object 5 * @param theQuery 6 */ 7 function typeAhead(theQuery) { 8 var aSuggestions = searchManager.getTypeAheadSuggestions( 9 context.getUser(), 10 context.getACL(), 11 theQuery 12 ); 13 for (var i = 0; i < aSuggestions.length; i++) { 14 REST.push(null, aSuggestions[i], false); 15 } 16 } 17 18 /** 19 * @name TypeAhead 20 * @class Provide search options from R3search given a query 21 * @description This endpoint searches R3search possible search options given a string 22 * @param [search] A string to search on 23 * @returns ["MatchedString", ... ] 24 * 25 * @example /wf/restapi/v2/typeAhead 26 * 27 * Parameters: 28 * search=test 29 * 30 Response: 31 [ 32 "test", 33 "test A", 34 "test B" 35 ] 36 * @example /wf/restapi/v2/typeAhead 37 * 38 * Parameters: 39 * search=test A 40 * 41 Response: 42 [ 43 "test A" 44 ] 45 */ 46 (function main() { 47 //Only routing through the callback here so that we can utilize the default error handling 48 REST.setCallback(typeAhead); 49 return REST.execute("search"); 50 })(); 51