AnsweredAssumed Answered

SugarQuery Joinraw alternative for email related tables

Question asked by Jeroen Somhorst on Apr 13, 2018
Latest reply on Apr 16, 2018 by Jeroen Somhorst

For a customer we are in the process of upgrading from 7.6.x to 7.9.3. Many things have changed over the time and therefore we face lots of issues. One of these issues that we are facing is the depcrecation of the joinRaw() function on SugarQuery. 

 

In the original code we are adding two joinraw strings to the sugarquery object to :

 

$SugarQuery->joinRaw ( "LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = " . strtolower ( $module ) . ".id" );
$SugarQuery->joinRaw ( "LEFT JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id" );

I already found out that I should use joinTable() as the alternative but I can't seem to get it working. 

When adding the following snippets I do get an SQL query error that is related to the joinTable calls:

 

$SugarQuery->joinTable("email_addr_bean_rel")->on()
    ->equalsField($module . '.bean_id', 'email_addr_bean_rel.id');

$SugarQuery->joinTable("email_addresses")->on()
    ->equalsField("email_addr_bean_rel.id","email_addresses.email_address_id");

How can I solve this by using the joinTable method?

Outcomes