Results 1 to 7 of 7

Thread: Dashlets are ruining my day: Or, using a Custom Field as a filter

  1. #1
    leenwebb is offline Sugar Community Member
    Join Date
    Nov 2006
    Location
    New Hampshire
    Posts
    77

    Default Dashlets are ruining my day: Or, using a Custom Field as a filter

    Hi all,
    I am trying to customize the MyContactsDashlet on my home page. I am not having any luck.

    Here's what I'm going for: I have a custom field in Contacts called Status (AKA contact_status_c). It has three possible values, and I want the dashlet to only display Contacts whose status is "Awaiting Action".

    In modules/Contacts/Dashlets/MyContactsDashlet/MyContactsDashlet.data.php , I added this line to the "Search Field" array at the top of the file:

    Code:
    'contact_status_c'=> array('default' => 'Awaiting Action'),
    And when I try to view the homepage I get this error:

    Code:
    Warning: LayoutManager::require_once(include/generic/SugarWidgets/SugarWidgetFieldrelate.php)
    [function.require-once]: failed to open stream: No such file or directory in
    /var/www/ucds/code/include/generic/LayoutManager.php on line 251
    I'm not sure why it's looking for SugarWidgetFieldrelate.php, or why it thinks its class in that case is 'relate'.

    On a whim, I take out the "Awaiting Action" so that it says

    Code:
    'contact_status_c'=> array('default' => ''),
    Now the homepage loads, but when I go to the MyContacts dashlet edit screen, it says
    Code:
    "There was an error handling this request!"
    Anyway, since it's a custom field, I thought maybe it could help if I gave the field a table name to go with it. (Don't look at me like that -- this exact thing has worked in sugar before!)
    Code:
    'contacts_cstm.contact_status_c'=> array('default' => ''),
    Now if I try to edit the dashlet, the normal edit screen shows up. But in the place of a nice selection box where I can choose to filter by status, I get
    Code:
    -- Not Implemented --
    I've read the dashlet wiki, and I have no idea what this "Not Implemented" business is, or why it would be so hard to add in a filter-able field to a dashlet. I have searched the forums and found a few other posts where this same issue was related, but never solved (or even really explored). Developers, experts, anyone?

    Thanks
    Eileen



    P.S.! If the code reads:
    Code:
    'contacts_cstm.contact_status_c'=> array('default' => 'Awaiting Action'),
    Then I get a whole different error on the homepage. Like so:

    Code:
    Fatal error: Call to undefined method SugarWidgetField::queryFilterStarts_With()
    in /var/www/ucds/code/include/Dashlets/DashletGeneric.php on line 261

  2. #2
    Scott_Savage is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Sydney, Australia
    Posts
    193

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    I am trying to do the exact same thing and am unfortunately getting the exact same results. I don't want to have to write my own dashlet to fix this problem... Does anyone have any ideas?
    Web Server: IIS 6, Win2k3
    PHP: 5.2.5
    MySQL: 5.0.27-community-nt
    Sugar: 4.5.0j Open Source
    Website: www.scottsavage.net

  3. #3
    leenwebb is offline Sugar Community Member
    Join Date
    Nov 2006
    Location
    New Hampshire
    Posts
    77

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    Hi Scott,
    I ended up solving my particular problem in a whole different way...

    I'll preface by saying that I didn't want a 'sometimes' filter; I wanted an 'all-the-time' filter. I have a custom Contacts field called "Status", and I only wanted to display contacts with a particular status ('Awaiting Action'). So my solution is an all-the-time solution, as opposed to a filter you could turn on-or-off when necessary.

    Anyway. Here's what I ended up doing: In include/dashlets/DashletGeneric.php, there is a function called 'buildWhere' (~line 225). It builds the query that populates the dashlet. I added this code into that function around line 270, before the 'return $returnArray' line :

    Code:
    // custom filters!  TAME THE WILD DASHLET!
    $module = get_class($this);
    		
    if ($module == 'MyContactsDashlet'){
         array_push($returnArray,'contact_status_c="Awaiting Action"');
    
    }
    The $module variable grabs the dashlet name (since this function applies to all dashlets, and I only wanted to edit the MyContactsDashlet). Then the if() just adds in the extra restriction to the array that will eventually be turned into the 'where' part of the SQL statement.

    I have no idea if this is upgrade-safe, or kosher, or whatever. But it works! Hopefully your dashlet editing will be relatively painless.

    Good luck!
    Eileen

  4. #4
    Scott_Savage is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Sydney, Australia
    Posts
    193

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    Awesome thanks!!! This is exactly what I needed...
    Web Server: IIS 6, Win2k3
    PHP: 5.2.5
    MySQL: 5.0.27-community-nt
    Sugar: 4.5.0j Open Source
    Website: www.scottsavage.net

  5. #5
    jmaxwell is offline Sugar Community Member
    Join Date
    Jul 2005
    Posts
    51

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    Eileen, thanks for sharing the info. I will likely implement something similar on our installation too (coincidentally we are also in NH).

    I think the reason you can't just add custom fields to the dashlet configuration file is for some reason the contacts_cstm table is not joined for the listview query, thus it doens't know where or how to find the custom field. If you can find a way to join that table to the query, all the custom fields should be searchable.

    This is pretty wacky (big suprise! not...) on the part of sugar, since the custom fields ARE joined for the query to display the dashlet info. (e.g. you can choose custom fields to show in the dashlet list view from the dashlet configuration screen... but cant' choose custom fields for the search options... typical sugar.)

    thanks
    -Ed

  6. #6
    mergulhao83 is offline Sugar Community Member
    Join Date
    Dec 2006
    Posts
    27

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    I've got the solution for the "'sometimes' filter". Adding filter with custom fields in the dashlets. Needs some code modification.

    Here is the thread:
    http://www.sugarcrm.com/forums/showthread.php?p=67044

    Mergulhão

  7. #7
    mkenigson is offline Sugar Community Member
    Join Date
    Sep 2006
    Location
    Nashville, TN
    Posts
    83

    Default Re: Dashlets are ruining my day: Or, using a Custom Field as a filter

    Quote Originally Posted by leenwebb
    Hi Scott,
    I ended up solving my particular problem in a whole different way...

    [snip]

    I have no idea if this is upgrade-safe, or kosher, or whatever. But it works! Hopefully your dashlet editing will be relatively painless.

    Good luck!
    Eileen
    Eileen,

    Bless you! You just saved me hours or days of hunting and ripping hair out. If you're ever in Nashville look me up -- I owe you a decent meal!

    Matt K.

Thread Information

Users Browsing this Thread

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

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
  •