AnsweredAssumed Answered

Simple SugarQuery using a custom field returns no results

Question asked by Artis Plocins on Jul 10, 2017
Latest reply on Jul 18, 2017 by Artis Plocins

I created a custom Integer field called ticket_id_c in the Cases module and I can clearly see the field having the value my code is looking for in the cases_cstm table, but I still get no results.

$sq = new SugarQuery();
$sq->where()->equals('ticket_id_c', (int) $ticket['id']);
$result = $sq->execute();
$count = count($result);
$GLOBALS['log']->fatal('Result count: ' . $count);
// Outputs 0 to the log - no results
$GLOBALS['log']->fatal('Results: ' . $result);
// Outputs "()" to the log


I thought maybe I need to join the cases_cstm table in the query, but I could not find enough information to do that without errors. But surely the Cases bean should include the custom table as well?


How can I correctly perform this Sugar Query?