I'm trying to write a simple query in Sugar 7.2 that will join a table. This SQL is what I'm trying to create in the Sugar framework using SugarQuery().
SELECT * FROM keyname_table_a LEFT JOIN keyname_table_b
So what I've created is the following. It works just fine when I use the core modules, but if I switch it to custom modules that we've created, Sugar logs me out and brings me to a login prompt.
$query = new SugarQuery();
$query->from(BeanFactory::getBean('keyname_table_a'));
$query->join('keyname_table_b');
$results = $query->execute();
return print_r($results, true);
The above logs me out and gives me the following error message in a popup message (similar to how app.alert.show works), and logs me out.
Error: Request failure, or, missing/invalid parameter. Please contact technical support
If I replace the "from" and "join" tables to be "Accounts" and "cases" respectively, then the query works just fine and pulls in the expected result. However, switching it to the custom modules that we have results in the above error and we are logged out instantly.
I have verified that the relationship exists and there is data linking the two together. It is a one to many relationship in Sugar. table_a
is one, while table_b
is many.
What is the proper way to join two custom modules with the SugarQuery()
object?