I want to add an if statement before searching that if the query string is available on my select sql statement then I will change the value of the query string based on the result. How can I implement this?
$sql = “SELECT name FROM table WHERE quote_id = ‘{$queryString}’”;
$name= $GLOBALS[‘db’]->getOne($sql);
$queryString = $name ? $name: $queryString;
HI Thank you for your reply. Sorry I’m new to suite crm. I have this table that I think is not included on the module. This table have the ID that I want to search. Like so.
table: not included
id other_id
table:included
other_id
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class GlobalSearchLogicHook{
function GlobalSearchLogicHook(){
if($_REQUEST['action'] == 'UnifiedSearch' && $_REQUEST['module'] == 'Home' && $_REQUEST['custom'] != 'query'){
$randomNumber = rand();
$queryString = $_REQUEST['query_string']; // get query string
//check query string record is exist or not in table
$sql = "SELECT name FROM table WHERE quote_id = '{$queryString}'";
$name = $GLOBALS['db']->getOne($sql);
$queryString = $name ? $name: $queryString;
//assign query string to the js
echo "<script type='text/javascript'>var queryString = ".$queryString."</script>";
echo '<script type="text/javascript" src="custom/include/GlobalSearchLogicHook/GlobalSearchLogicHook.js?v='.$randomNumber.'"></script>';
}//end of if
}//end of function
}//end of clas
3) custom/include/GlobalSearchLogicHook/GlobalSearchLogicHook.js
$( document ).ready(function() {
//redirect to the result with updated query string
window.location.href = "index.php?action=UnifiedSearch&module=Home&search_form=false&advanced=false&query_string="+queryString+"&custom=query";
});//end of function