How to search Active and Inactive users in Sidecar module filters?

Hello,

In sidecar modules, the 'Assigned to' filter returns only Active users?

Is there a way to search Inactive users as well?

I have SugarCRM 8.2 Pro.

I followed the below post and was able to search inactive users in bwc modules but not in sidecar.

How can you populate active and inactive users in Assigned To field? 

Please help.

Thanks,
Shantanu

  • Hi Shantanu,

    You can extend the PersonFilterAPI (clients/base/api/PersonFilterApi.php) in order to do this and check the method getCustomWhereForModule. That method can be extended or you can create your own to add the 'Inactive' status on the below line:


    if ($module == 'Employees') {
    $query->where()->equals('employee_status', 'Active')->equals('show_on_employees','1');
    return;
    }

    // TODO: Add Inactive status here
    $query->where()->equals('status', 'Active')->equals('portal_only', '0');
    return;
    }

    Note that after changing this, anyone can now filter or assign records to Inactive users.

    Regards,

    Kaizer

  • Thanks a lot Kaizer. This worked for me.

    Regards,

    Shantanu Agnihotri

  • HI Kaizer,

    I was trying to implement the same and its working on local machine but when I created package and tried to install sugarcrm but system throws error "Installation failed and when I checked in logs it shows [Scanner] [STATUS] VERDICT: A", can you please suggest what might be the issue?

    My manifest file:

    "

    <?php
    $manifest = array (
    'built_in_version' => '12.0.0',
    'acceptable_sugar_versions' =>
    array (
    0 => '12.*.*',
    1 => '13.*.*',
    ),
    'acceptable_sugar_flavors' =>
    array (
    0 => 'ENT',
    1 => 'ULT',
    ),
    'readme' => '',
    'key' => '',
    'author' => 'ABC',
    'description' => 'CustomPersonFilterApi to allow inactive users also',
    'icon' => '',
    'is_uninstallable' => true,
    'name' => 'CustomPersonFilterApi',
    'published_date' => '2023-09-24',
    'type' => 'module',
    'version' => 1.0,
    'remove_tables' => 'prompt',
    );

    $installdefs = array(
    'id' => 'CustomPersonFilterApi',
    'copy' => array (
    0 =>
    array(
    'from' => '<basepath>/Files/custom/clients/base/api/CustomPersonFilterApi.php',
    'to' => 'custom/clients/base/api/CustomPersonFilterApi.php',
    ),
    )
    );
    ?>

    "

    ***************************************************************

    My "CustomPersonFilterApi.php"

    "

    <?php
    /*
    * Your installation or use of this SugarCRM file is subject to the applicable
    * terms available at
    * support.sugarcrm.com/.../.
    * If you do not agree to all of the applicable terms or do not have the
    * authority to bind the entity as an authorized representative, then do not
    * install or use this SugarCRM file.
    *
    * Copyright (C) SugarCRM Inc. All rights reserved.
    */

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    require_once("clients/base/api/PersonFilterApi.php");

    class CustomPersonFilterApi extends PersonFilterApi
    {
    public function registerApiRest()
    {
    //in case we want to add additional endpoints
    return parent::registerApiRest();
    }

    //override to modify the ping function of the ping endpoint
    /**
    * Gets the proper query where clause to use to prevent special user types from
    * being returned in the result
    *
    * @param string $module The name of the module we are looking for
    * @return string
    */
    protected function getCustomWhereForModule($module, $query = null) {
    $GLOBALS['log']->fatal('Inside my custom function...');

    if ($query instanceof SugarQuery) {
    if ($module == 'Employees') {
    $query->where()->equals('employee_status', 'Active')->equals('show_on_employees','1');
    return;
    }

    // This allows us to filter on active or inactive users
    $w = $query->where()->equals('portal_only', '0');
    if ($this->useOnlyActiveUsers) {
    //$w->equals('status', 'Active');
    }
    return;
    }

    if ($module == 'Employees') {
    return "users.employee_status = 'Active' AND users.show_on_employees = 1";
    }

    // Same here... allow filtering of active or inactive users
    // $r = $this->useOnlyActiveUsers ? "users.status = 'Active' AND " : '';
    return "$r users.portal_only = 0";
    }
    }

    "

    Kindest Regards,

    Shreya

  • Hi Shantanu,

    Can you please guide me on how you extended getCustomWhereForModule?

    Kindest Regards,

    Shreya