I created a new Accounts dashlet, based on the current MyAccountsDashlet, modified so it would only display Accounts that had been Favourited (by the manager signed in, regardless of who the account is assigned to) and also in a particular team and industry.
So I copied the dashlet and added the extra custom select:
When configuring the dashlet, I turned off 'My Records' as I knew that would have restricted it to Accounts assigned to the manager, which we don't want.PHP Code:function process($lvsParams = array()) {
global $current_language, $app_list_strings, $image_path, $current_user;
$lvsParams = array(
'custom_select' => '',
'custom_from' => '',
'custom_where' => ' AND accounts.id in (select record_id from sugarfavorites sf where sf.module = "Accounts" and deleted = "0" )',
'distinct' => true
);
parent::process($lvsParams);
}
}
I thought that would have worked, but when I looked at the Sugarcrm.log file to see what was executed, this is the full SQL statement:
PHP Code:SELECT DISTINCT accounts.id , accounts.name , accounts.phone_office , accounts.date_entered , accounts.assigned_user_id , sfav.id is_favorite FROM accounts LEFT JOIN sugarfavorites sfav ON sfav.module ='Accounts' AND sfav.record_id=accounts.id AND sfav.assigned_user_id='1' AND sfav.deleted=0 where ((accounts.team_id IN ('East','1','West')
) AND (accounts.industry IN ('Transportation')
)) AND accounts.deleted=0 AND accounts.id in (select record_id from sugarfavorites sf where sf.module = "Accounts" and deleted = "0" ) ORDER BY accounts.date_entered DESC LIMIT 0,6
This was a spanking new installation of Sugarcrm Pro, used purely locally for testing, so I had included all the sample data, and I was logged in as user 1.
It looks like Sugar added an extra Join in, that I didn't want.
Is there an easy way of completely customising the SQL executed in a dashlet, rather than just adding an extra condition?
cheers


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks