Where to manipulate querys deshlets?

Hi!
I have change fields in the dashlets. which file handle the opportunities dashlets
Thanks!

You can manipulate the dashlets from Studio (Opportunities > Layouts > Dashlet)

If you need to adapt the query, or really change the code, you can override the class (adapt from this one):

https://developer.sugarcrm.com/2011/05/24/howto-custom-accounts-dashlet-that-show-records-without-related-calls/

Hi!
Thanks for help.
I have change dashlet graphics for all opportunities by source and result. I need change SUM(total) to field in table custom.
Believe have change sql code, but I do not know where to change.

Thanks!

Hi!

I was able to change in modules/chats/deshlets. The .php for example OpportunitiesByLeadSourceByOutcomeDashlet.php. I change the query in function constructQuery. Now works perfectly.

Thanks!!!

If you can share your code it might help somebody else in the future. We need more working examples in these forums! Thanks!

of course

for exemple in modules/Charts/Dashlets/MyPipelineBySalesStageDashlet/MyPipelineBySalesStageDashlet.php

the function

protected function constructQuery()
{
$query =" SELECT opportunities.sales_stage,
users.user_name,
opportunities.assigned_user_id,
count(*) AS opp_count,
sum(opportunities_cstm.toneladas_c) AS total
FROM
users,
opportunities,
opportunities_cstm";
$query .= " WHERE
opportunities.assigned_user_id IN (’{$GLOBALS[‘current_user’]->id}’) " .
" AND opportunities.date_closed >= “. db_convert(”’".$this->mypbss_date_start."’",‘date’).
" AND opportunities.date_closed <= “.db_convert(”’".$this->mypbss_date_end."’",‘date’) .
" AND opportunities.assigned_user_id = users.id AND opportunities.deleted=0
AND opportunities.id = opportunities_cstm.id_c ";

        if ( count($this->mypbss_sales_stages) > 0 )
            $query .= " AND opportunities.sales_stage IN ('" . implode("','",$this->mypbss_sales_stages) . "') ";
            $query .= " GROUP BY 
                        opportunities.sales_stage ,
                        users.user_name,
                        opportunities.assigned_user_id";

    
    //echo $query;
    return $query;
}