Results 1 to 2 of 2

Thread: Setting default filters for multiple dashlets

  1. #1
    marclangston is offline Sugar Community Member
    Join Date
    Oct 2009
    Posts
    98

    Default Setting default filters for multiple dashlets

    I am creating a default homepage for my users. Among other things, the homepage will have two instances of the "My Leads" dashlet. One instance will show "open/new leads created in the past 30 days". (I can't remember if it's part of some previous customization or if it's built in to Sugar, but I already have the "in the past 30 days" logic.) The second instance will show "unconverted leads that were created more then 30 days ago". (Again, I already have the ">30 days" filter).

    So far I have been able to force the homepage to show the two instances of the Leads dashlet, and I can get those instances to have different titles and displayed columns. The code is in custom\modules\Home\index.php and looks like this:

    PHP Code:
            $dashlets[create_guid()] = array('className' => 'MyLeadsDashlet',
                                             
    'module' => 'Leads',
                                             
    'forceColumn' => 0,
                                             
    'fileLocation' => $dashletsFiles['MyLeadsDashlet']['file'],
                                             
    'options' => array('title' => translate('OPEN LEADS created in the last 30 days','Leads'),
                                                                
    'displayColumns' => array('account_name',
                                                                                    
    'name',
                                                                                    
    'title',
                                                                                    
    'phone_work')
                                                 ));

            
    $dashlets[create_guid()] = array('className' => 'MyLeadsDashlet',
                                             
    'module' => 'Leads',
                                             
    'forceColumn' => 1,
                                             
    'fileLocation' => $dashletsFiles['MyLeadsDashlet']['file'],
                                             
    'options' => array('title' => translate('UNCONVERTED LEADS created >30 days ago','Leads'),
                                                                
    'displayColumns' => array('date_entered',
                                                                                    
    'account_name',
                                                                                    
    'name',
                                                                                    
    'phone_work')
                                                 )); 
    I can't figure out how to specify which filter criteria each of the dashlets should be using. If I wanted to have the same filters on both of them I think I could change something in the dashlet.data.php file, but then both instances of the dashlet would filter on the same criteria.

    Can somebody tell me what the code looks like that can specify the filters on a per-dashlet basis? I've been thinking it would be in an "options" section but so far I haven't figured out exactly what the syntax might be.

    Thanks.
    marc

  2. #2
    marclangston is offline Sugar Community Member
    Join Date
    Oct 2009
    Posts
    98

    Default Re: Setting default filters for multiple dashlets

    Update: I've figured out how to filter on the 'name' field. It goes below the 'displayColumn' code like this:

    PHP Code:
    $dashlets[create_guid()] = ...
    .
    'displayColumns' => array('account_name',
                                 
    'name',
                                  
    'title',
                                  
    'phone_work'),
    'filters' => array('name' => 'John Smith')
    )); 
    That would allow me to set the default filter for this instance of the dashlet to show only those Leads with the name 'John Smith' (which is of limited value but at least shows I can do some sort of filtering). I've tried some variations of the array statement to set a date range but so far haven't cracked that code.

    Does anybody know how I can set filter on a date, date range, or a status (like all 'New' or 'Assigned' leads)?
    Thanks.
    marc

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Filters in Dashlets
    By unclebuck in forum Developer Help
    Replies: 2
    Last Post: 2010-10-15, 08:55 PM
  2. Dashlets + Filters
    By chrislynch8 in forum Developer Help
    Replies: 11
    Last Post: 2010-06-18, 04:52 AM
  3. Filters in Dashlets
    By EDUCASTREAM in forum Developer Help
    Replies: 4
    Last Post: 2010-02-22, 08:15 PM
  4. Replies: 0
    Last Post: 2009-02-23, 07:30 AM
  5. Case Dashlets returning bad filters
    By eggsurplus in forum Developer Help
    Replies: 2
    Last Post: 2007-08-23, 03:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •