How to create a filter to select any records

I followed the Sugar Developer Guide on how to create a predefined filter however I am attempting to create a filter that populates on a specific module for all users, using ‘is any of’ so that the user can select from a list of records.

I have tried but failed, can anybody provide me with a sample noting that I only have access to the custom folder.

I know the users can create this themnselves but we would like to create this globally. 

Thank you so much,

Christopher

  • I know you are the expert, do you by any chance have any guidance please and thank you

  • ,

    Thanks for the compliment! From my understanding, there isn't a way to make a predefined filter open-ended where users can specify the filter criteria. You can create a filter that will show for all users though that mimics what you have shown in your screenshot. I created the following file:

    ./custom/Extension/modules/Emails/Ext/clients/base/filters/basic/filterEmailFrom.php

    The file has the following contents:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <?php
    $viewdefs['Emails']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterEmailFrom',
    'name' => 'Email From', // I found this has to be the filter name (not a label key) when editable is set to true
    'filter_definition' => array(
    array(
    'from_collection' => array(
    '$in' => array( // Setting this to an empty array achieves your desired affect of the filtered values for the field being empty
    ),
    ),
    ),
    ),
    'editable' => true, // When this is set to false, it will show in the predefined filter list for users but will not allow your users to enter their own filtered values
    'is_template' => false,
    );
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    After creating the file, I performed a quick repair on the instance and cleared my browser cache to be able to see the new list view filter:

    After selecting the filter, I could click the filter to edit the filter criteria like other user-defined filters:

    I confirmed all users could see the filter and search on the criteria they wanted. The experience overall isn't the best though because if they try to delete or save the filter, they will receive an error popup. I believe this is because user-defined filters are typically stored in the filters table in the database. Since this filter exists in code, Sugar does not know how to handle the save or delete requests.

    I hope this helps!

    Chris