Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : User Interface Customizations : Adding QuickSearch to a Custom Field

Adding QuickSearch to a Custom Field
1.
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
2.
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
'team_name' => $qsd->getQSTeam());
Notes on structure of config - replace the default parameters if they are different for the page.
o
method: Unless you make a new method on the JSON server, keep this as query.
o
populate_list: This defines the id's of the fields to be populated after a selection is made.
QuickSearch will map the first item of field_list to the first item of populate_list. ie. field_list[0] = populate_list[0], field_list[1] = populate_list[1].... until the end of populate list.
o
limit: reduce from 30 if query is large hit, but never less than 12.
o
conditions: options are like_custom, contains, or default of starts with
if using 'like_custom' also define 'begin'/'end' for strings to prepend and postpend to the user input
o
disable: set this to true to disable SQS (optional, useful for disabling SQS on parent types in calls for example)
o
post_onblur_function: this is an optional function to be called after the user has made a selection. It will be passed in an array with the items in field_list as keys and their corresponding values for the selection as values.
$sqs_objects = array('account_name' => // this is the id
array(
// the method on to use on the JSON server
'method' => 'query',
'modules' => array('Accounts'), // modules to use
'field_list' => array('name', 'id'), // columns to select
'populate_list' => array('account_name', 'account_id'), // id's of the html tags to populate with the columns.
'conditions' => // where clause, this code is for any account names that have A WORD beginning with ...
array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>''),
array('name'=>'name','op'=>'like_custom','begin'=>'% ','end'=>'%','value'=>'')),
'group' => 'or', // grouping of the where conditions
'order' => 'name', // ordering
'limit' => '30', // number of records to pull
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH'] // text for no matching results
),
3.
$quicksearch_js = '<script type="text/javascript" src="' . getJSPath('include/javascript/sugar_grp1.js') . '"></script>';
4.
Assign your config array to sqs_objects (important!)
$quicksearch_js .= '<script type="text/javascript" language="javascript">
sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
5.
$javascript->addToValidateBinaryDependency('account_name', 'alpha',
app_strings['ERR_SQS_NO_MATCH_FIELD'] .
$mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
6.
<input class="sqsEnabled" id="account_name" name='account_name' size='30' type='text' value="{ACCOUNT_NAME}">
<input id='account_id' name='account_id' type="hidden" value='{ACCOUNT_ID}'>
 
Having trouble? Take a look at the file module/Contacts/BusinessCard.php.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License