Override Lead Dashlet

I just want to override Lead dashlet in upgrade safe manner. Can anybody help me to do thatā€¦

Hi there,

You can use the custom directory to add custom functionality to the Leads module.

Thanks,

Will.

i tried the same , but it gives the error ā€œFatal error: Cannot redeclare class MyLeadsDashlet in /path/to/core/file/modules/Leads/Dashlets/MyLeadsDashlet/MyLeadsDashlet.phpā€

Use http://www.sugarforge.org/frs/?group_id=1315 this is a dashboard manager compatible with suite crm :slight_smile:

I tried installing this and received an error.

03/19/14 13:06:31 [1464][1d5d0a22-4cbd-cd42-ece7-52f01706f73f][FATAL] Error altering column(s) user_default on table: dash_dashboardbackups: Query Failed: ALTER TABLE dash_dashboardbackups DROP CONSTRAINT DF__dash_dash__user___60924D76 ALTER TABLE dash_dashboardbackups ALTER COLUMN user_default bit NULL
ALTER TABLE dash_dashboardbackups ADD DEFAULT ā€˜0ā€™ FOR user_default ::: [Microsoft][SQL Server Native Client 11.0][SQL Server]ā€˜DF__dash_dash__user___60924D76ā€™ is not a constraint.
[Microsoft][SQL Server Native Client 11.0][SQL Server]Could not drop constraint. See previous errors.

not sure what to doā€¦

Tammy

found more:

Installing administration extension
Installing Language Packs
Rebuilding Languageā€¦en_us
Rebuilding Languageā€¦bg_BG
Rebuilding Languageā€¦cs_CZ
Rebuilding Languageā€¦da_DK
Rebuilding Languageā€¦de_DE
Rebuilding Languageā€¦es_ES
Rebuilding Languageā€¦et_EE
Rebuilding Languageā€¦fr_FR
Rebuilding Languageā€¦he_IL
Rebuilding Languageā€¦hu_HU
Rebuilding Languageā€¦it_it
Rebuilding Languageā€¦lt_LT
Rebuilding Languageā€¦ja_JP
Rebuilding Languageā€¦nb_NO
Rebuilding Languageā€¦nl_NL
Rebuilding Languageā€¦pl_PL
Rebuilding Languageā€¦pt_PT
Rebuilding Languageā€¦ro_RO
Rebuilding Languageā€¦ru_RU
Rebuilding Languageā€¦sv_SE
Rebuilding Languageā€¦tr_TR
Rebuilding Languageā€¦zh_CN
Rebuilding Languageā€¦pt_br
Rebuilding Languageā€¦ca_ES
Rebuilding Languageā€¦en_UK
Rebuilding Languageā€¦sr_RS
Installing layoutdefs extension
Installing vardefs extension
Rebuilding ActionViewMapā€¦
Rebuilding ActionFileMapā€¦
Rebuilding ActionReMapā€¦
Rebuilding Administrationā€¦
Rebuilding EntryPointRegistryā€¦
Rebuilding Extensionsā€¦
Rebuilding FileAccessControlMapā€¦
Rebuilding Layoutdefsā€¦
Rebuilding GlobalLinksā€¦
Rebuilding LogicHooksā€¦
Rebuilding Menusā€¦
Rebuilding Includeā€¦
Rebuilding ScheduledTasksā€¦
Rebuilding UserPageā€¦
Rebuilding Utilsā€¦
Rebuilding Vardefsā€¦
Rebuilding JSGroupingsā€¦
Rebuilding Actionsā€¦
Installing Images
Installing Relationships
Rebuilding Vardefsā€¦
Rebuilding Layoutdefsā€¦
Rebuilding TableDictionaryā€¦
Installing Bean : dash_DashboardBackups
Installing Bean : dash_DashboardManager

Database failure. Please refer to sugarcrm.log for details.

what version of suite crm are you using?

i have used the same with suite crm 7.0.2 and it is working perfect

Try to extend the class not just redeclaire it in the custom folder like below


//require_once('path/to/MyLeadsDashlet.php');
class MyCustomMyLeadsDashlet extends MyLeadsDashlet {

//overide the methods/functions in here

}
1 Like

thanks for your reply Andy. Can you please explain me more clearly.

safwanbe: Its not easy to explain more clearly, you really need to know what your doing with PHP to be able to develop a custom dashlet! Whats you programming expariance level?

1 Like

its been more than 3 year i am working in php ā€¦

Ok take a look at this link: https://www.atcoresystems.com/blog/introduction-to-creating-sugarcrm-dashlets

if your an experianced pho developer then that should help a lot.

@andy : actually what i want to do is instead of listing only the leads of the logged in user it has to list his subordinates also. in the sense ā€œMy Leadsā€ should list all the leads of logged in user plus all the leads of his subordinates.

So how has the relationship between the user and the subordinates been setup?

1 Like

Looked into this for you, thereā€™s a fair amount of work involved in that. You would basically have to create a complete new dashlet from scratch.

To get you started create:

custom/modules/Leads/Dashlets/MyCustomLeadsDashlet/MyCustomLeadsDashlet.data.php



<?php

global $current_user;
$dashletData['MyCustomLeadsDashlet']['searchFields'] = array('date_entered'     => array('default' => ''),
													   'title' => array('default' => ''),
													   'primary_address_country' => array('default' => ''),
                                                       //'status'           => array('default' => array('New', 'Assigned', 'In Process')), 
													   'assigned_user_id' => array('type'    => 'assigned_user_name',
																				   'label'   => 'LBL_ASSIGNED_TO',
                                                                                   'default' => $current_user->name));
 
$dashletData['MyCustomLeadsDashlet']['columns'] = array('name' => array('width'          => '30',
                                                                  'label'          => 'LBL_NAME',
                                                                  'link'           => true,
                                                                  'default'        => true,
                                                                  'related_fields' => array('first_name', 'last_name', 'salutation')), 
                                                  'title' => array('width' => '20',
                                                                   'label' => 'LBL_TITLE',
																   'default' => true),
                                                  'lead_source' => array('width' => '10',
                                                                         'label' => 'LBL_LEAD_SOURCE'),
                                                  'status' => array('width' => '10',
                                                                    'label' => 'LBL_STATUS'),
                                                  'phone_work' => array('width'   => '20',
                                                                        'label'   => 'LBL_OFFICE_PHONE',
                                                                        'default' => true),
                                                  'email1' => array('width' => '30',
                                                                    'label' => 'LBL_EMAIL_ADDRESS',
                                                                    'sortable' => false,
                                                                    'customCode' => '{$EMAIL1_LINK}{$EMAIL1}</a>',
																	'default' => true),
                                                  'account_name' => array('width' => '40', 
												  						  'label' => 'LBL_ACCOUNT_NAME'),
                                                  'phone_home' => array('width' => '10',
                                                                        'label' => 'LBL_HOME_PHONE'),
                                                  'phone_mobile' => array('width' => '10',
                                                                          'label' => 'LBL_MOBILE_PHONE'),
                                                  'phone_other' => array('width' => '10',
                                                                         'label' => 'LBL_OTHER_PHONE'),
                                                  'date_entered' => array('width'   => '15', 
                                                                          'label'   => 'LBL_LIST_DATE_ENTERED'),
                                                  'date_modified' => array('width'   => '15', 
                                                                           'label'   => 'LBL_DATE_MODIFIED'),    
                                                  'created_by' => array('width'   => '8', 
                                                                        'label'   => 'LBL_CREATED'),
                                                  'assigned_user_name' => array('width'   => '8', 
                                                                                'label'   => 'LBL_LIST_ASSIGNED_USER'),
                                                 );
?>

custom/modules/Leads/Dashlets/MyCustomLeadsDashlet/MyCustomLeadsDashlet.meta.php


<?php

$dashletMeta['MyCustomLeadsDashlet'] = array('module'		=> 'Leads',
									   'title'       => translate('LBL_CUSTOM_LIST_MY_LEADS', 'Leads'),
                                       'description' => 'A customizable view into Leads',
                                       'category'    => 'Module Views');

custom/modules/Leads/Dashlets/MyCustomLeadsDashlet/MyCustomLeadsDashlet.php


require_once('include/Dashlets/DashletGeneric.php');


class MyCustomLeadsDashlet extends DashletGeneric {
    function MyCustomLeadsDashlet($id, $def = null) {
        global $current_user, $app_strings;
		require('custom/modules/Leads/Dashlets/MyCustomLeadsDashlet/MyCustomLeadsDashlet.data.php');
		
        parent::DashletGeneric($id, $def);
         
        if(empty($def['title'])) $this->title = translate('LBL_CUSTOM_LIST_MY_LEADS', 'Leads');
        
        $this->searchFields = $dashletData['MyCustomLeadsDashlet']['searchFields'];
        $this->columns = $dashletData['MyCustomLeadsDashlet']['columns'];
        $this->seedBean = new Lead();        
    }
}

custom/modules/Leads/language/en_us.lang.php


<?php
// created: 2014-03-24 12:48:15
$mod_strings = array (
    'LBL_CUSTOM_LIST_MY_LEADS' => 'Custom Leads',
);

Do a quick reapir and rebuild and you will see the Custom leads dashlet appear in the add dashlet panel. Now its up to you to edit the files to do what your asking.

used ā€˜reports toā€™ field