Ok it appears I may have found my problem after looking at my log file and the /include/javascript/quicksearch.js file.
It seems that even when I had multiple conditions in my QuickSearch defaults all of my conditional values would always change to whatever it was that I had typed into the textbox. EVEN when the 'value' variable was explicitly set in the QuickSearchDefaults.php file.
I am running version 4.5.0b (Build 1144) and I am not sure if this will be corrected in future versions but here is my work around.
First here is my customized include/QuickSearchDefaults.php function:
Code:
function getQSSupplierAccounts($theid, $thename, $thestreet, $thecity, $thestate, $thepostalcode, $thecountry) {
global $app_strings;
$qsAccounts = array(
'method' => 'query',
'modules' => array('Accounts'),
'group' => ' AND ',
'field_list' => array('name', 'id', 'billing_address_street', 'billing_address_city', 'billing_address_state', 'billing_address_postalcode', 'billing_address_country'),
'populate_list' => array($thename, $theid, $thestreet, $thecity, $thestate, $thepostalcode, $thecountry),
'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>''), array('name'=>'account_type','op'=>'contains','value'=>'Supplier')),
'order' => 'name',
'limit' => '30',
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
);
return $qsAccounts;
} Now this is the code that I modified in the include/javascript/quicksearch.js file under the 'makeRPCCall' function:
Code:
function makeRPCCall(upEl, sqs_id) {
if(typeof(sqs_objects[sqs_id]) != 'undefined') {
window.clearTimeout(callDelay);
if(sqs_objects[sqs_id]['multi'])
sqs_query = getUserInputToMatch(document.getElementById(sqs_id).value);
else
sqs_query = document.getElementById(sqs_id).value;
if(typeof(siw) != 'undefined' && sqs_query == '') hideSmartInputFloater(false);
sqs_query = sqs_query.replace(/\\/gi,'').replace(/\[/gi,'').replace(/\(/gi,'').replace(/\./gi,'\.').replace(/\?/gi,'');
sqs_query = sqs_query.replace(/[()]+/g,'');
if (sqs_query.length > 0) {
if(sqs_old_values[sqs_id].length > 0 && sqs_query.indexOf(sqs_old_values[sqs_id]) == 0
&& typeof(collection) != 'undefined' && collection.length > 0 && collection.length < sqs_objects[sqs_id]['limit']) { // don't make an RPC call, use cache
processSmartInput(upEl, sqs_id);
}
else if(sqs_old_values[sqs_id] != sqs_query) {
// wait gif
x = findElementPosX(upEl) - 19;
y = findElementPosY(upEl);
floaterWait.style.left = x;
floaterWait.style.top = y;
floaterWait.style.display="block";
floaterWait.style.visibility="visible";
for(var i = 0; i < sqs_objects[sqs_id]['conditions'].length; i++) {
if ((sqs_objects[sqs_id]['conditions'][i]['name'] == 'account_type')) {
if (JSON.parse(sqs_objects[sqs_id]['conditions'][i]['value']) == false){
sqs_objects[sqs_id]['conditions'][i]['value'] = JSON.stringify(sqs_objects[sqs_id]['conditions'][i]['value']);
}
}
else
{
sqs_objects[sqs_id]['conditions'][i]['value'] = JSON.stringify(sqs_query);
}
}
req_id = global_rpcClient.call_method(sqs_objects[sqs_id]['method'], sqs_objects[sqs_id]);
global_request_registry[req_id] = [SugarQuickSearchObject, 'display'];
}
}
sqs_old_values[sqs_id] = sqs_query;
sqs_object_id = sqs_id;
}
} Notice that under my conditions I was looking for a condition name of 'account_type'. If the condition name matched this then it would check to see if the value was already stringified if not then it would stringify the original value declared in the Quick Search defaults definitions and not the value being typed in the text box.
This work around was only for my own account type column under the accounts table but it should at least give you an idea of a work around until this bug is fixed in future versions.
Bookmarks