calculate and display total lead scores

Hi everyone

i’m customizing lead module. in the photo bellow

I want to calculate total scores at the bottom and display result in lead score field at the top

How can I do, thanks

You can see an example here of customizing a detail view by extending the class and redefining the Display function:

You can do something similar for leads, and you can use some SQL to do the SUM and display it.

You can see an example of direct SQL access here

Please share your solution once you finish it. Thanks


Thank you for your suggestion.
So how can i push value in a field on database.

i’ve resolve it, but must reload 2 times
This is my code

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.


class CustomLeadsViewDetail extends ViewDetail {
    public function display() {
    private function _updateLeadScore() {
            include_once 'data/SugarBean.php';

            $leadRecordId = $this->bean->id;
            $bean = new SugarBean();
            $query = "select sum(b.fs_score)as leadscore
            from leads_ldsco_fs_lead_score_1_c a
            inner join ldsco_fs_lead_score b
            on = a.leads_ldsco_fs_lead_score_1ldsco_fs_lead_score_idb
            where a.leads_ldsco_fs_lead_score_1leads_ida = "."'".$leadRecordId."'"." and a.deleted =0";
	    $result = $bean->db->query($query,true," Error filling in additional detail fields: ");
	    $row = $bean->db->fetchByAssoc($result);
            $insert = "update leads_cstm
                        set fs_lead_score_c =".$row[leadscore]."
                        where id_c = "."'".$leadRecordId."'"."";

            if($row[leadscore] != null){
                $result = $bean->db->query($insert,true," Error filling in additional detail fields: ");


That looks great, thanks for sharing!

Just one more detail for any users coming here in the future: where do you place that file, and what do you call it?

i place in custom/modules/Leads/views/view.detail.php