How to customize predefined filters in a Search

I have created a custom module called "Verkaufsangebote".

It has got 2 links to users. Backoffice and Field Rep.

Out of the box I get the following predefined filters:

"My Verkaufsangebote" refers to the Backoffice Rep.

How to add other filters?

How to customize the existing one?

  • Found maybe helpful definition here: custom/modules/<module>/clients/base/filters/default/default.php

  • Hi Günter,

    Customizing and adding predefined filters to the list view search must be done at a programmatic level if you wish for the filters to be available for all users. The Sugar Developer Guide covers how to add new filters.

    To customize one of the default filters installed with the module, you would apply the same concept as described in the developer guide to overwrite the existing definition. The standard list view filters found in each module (e.g. My Favorites, My <Module Name>, etc.) are derived from the following file:

    ./include/SugarObjects/templates/basic/clients/base/filters/basic/basic.php

    In that file, locate the filter_definition you want to overwrite and apply the same concept as described in the developer guide link I provided above. Where the guide falls short is providing an example on how to accomplish your scenario of filtering on user-related fields. The solution is also likely going to be different based on how you linked the custom module to users (e.g. custom relationship or a standalone relate field). If you need further help in this regard, let me know as that will take some deeper investigation. 

  • Hi Chris Raffle,

    thank you very much for your reply - that is awesome. The Sugar Developer Guide is very helpful and I already managed to create new filters for testing. You are right, the guide falls short for user related fields and that's exactly what I need.

    I want to define a condition like: (user1==currentRep or user2==currentRep)

    The fields were "auto-created" in studio by creating a relationship.

    Thanks for further support. Best regards, Günter

    Screenshot of Relationships:

  • I think I have made it by creating a new filter instead of changing the existing one.

    1) Define the label

    ..\custom\Extension\modules\Angeb_Angebot\Ext\Language\de_DE.customADID.php

    <?php
     $mod_strings['LBL_FILTER_ADID'] = 'Meine Verkaufsangebote (AD/ID)';
    ?>

    2) Define the filter

    ..\custom\Extension\modules\Angeb_Angebot\Ext\clients\base\filters\basic\customADID.php

    <?php

    global $current_user;

    $viewdefs['Angeb_Angebot']['base']['filter']['basic']['filters'][] = array(
        'id' => 'customADID',
        'name' => 'LBL_FILTER_ADID',
        'filter_definition' => array(
      '$or' => array (
       array(
        'users_angeb_angebot_1users_ida' => array(
         '$in' => array(
          $current_user->id,
         ),
        ),
       ),
       array(
        'users_angeb_angebot_2users_ida' => array(
         '$in' => array(
          $current_user->id,
         ),
        ),
       ),
      ),
        ),
        'editable' => false,
        'is_template' => false,
    );

    ?>

    3) Quick Repair

    Thanks Chris Raffle for the hint!

  • Awesome! I'm glad you were able to derive a solution, Günter