AnsweredAssumed Answered

Is this syntax correct for a sugar Query?

Question asked by James Palmisano on Jul 6, 2016
Latest reply on Jul 6, 2016 by Tevfik Tümer

I've been reading about sugar query and it seem straight forward, but as this is my first time with it I wanted to post something here to see if there is anyone with any pointers as what are best practices.


Problem : I need to select all emails from a table called cc_emails (created from module builder with person template with a many to many relationship to cases) where the case_id is a specific case ID.


My solution (I have no idea if this works or not or if this is the best practice) :

$sugarQuery = new SugarQuery();

//add fields to select

//fetch the bean of the module to query
$bean = BeanFactory::newBean('cc_emails');

//add from table of the module we are querying
$sugarQuery->from($bean, array('team_security' => false));

//add the where clause

//where the assigned_user_id field is equal to 'seed_sally_id'
->equals('case_id', 'someIdFromCaseBean');



Comments are appreciated