Filtering Targets by Converted/Unconverted

@pstevens

Module Prospects has the field ā€˜lead_idā€™. It has id of Lead after converting.
I found one interesting, standard and working way.

  1. copy files:
  • modules/Prospects/metadata/SearchFields.php --> custom/modules/Prospects/metadata/SearchFields.php
  • modules/Prospects/metadata/searchdefs.php --> custom/modules/Prospects/metadata/searchdefs.php
  1. Add code to files
  • custom/modules/Prospects/metadata/SearchFields.php:
...
$searchFields['Prospects'] =
    array(
// add code start
            'open_only_lead_conv' => array(
                'query_type'=>'format',
                'operator' => 'subquery',
                'subquery' => "SELECT prospects.id FROM prospects
                                                WHERE prospects.deleted = 0
                                                    and prospects.lead_id IS NOT NULL",
                'db_field'=>array('id')
            ),
// add code finish
...
  • custom/modules/Prospects/metadata/searchdefs.php
...
    'layout' => array(
        'basic_search' => array(
            array('name' => 'search_name', 'label' => 'LBL_NAME', 'type' => 'name'),
            array('name' => 'current_user_only', 'label' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
// add line
            array('name' => 'open_only_lead_conv','label' => 'LBL_CONVERTED_LEAD','type' => 'bool',),
...
2 Likes