Pass Php Array to Javascript using JSON – Sugar CRM


Consider that we are restricting user to assign a case to his/her reporting person so create the file like below as view.edit.php in custom/module/cases/view/ .
The functions which are used to get reporting person of current user are in another post getReportsToUserArray(); getUserIdByPrivateTeam();

require_once('include/EditView/EditView2.php');

class CasesViewEdit extends SugarView {

    var $ev;
    var $type = 'edit';
    var $useForSubpanel = true;  //boolean variable to determine whether view can be used for subpanel creates
    var $useModuleQuickCreateTemplate = false; //boolean variable to determine whether or not SubpanelQuickCreate has a separate display function
    var $showTitle = true;

    function CasesViewEdit() {
        parent::SugarView();
    }

    /**
     * @see SugarView::preDisplay()
     */
    public function preDisplay() {
        $metadataFile = $this->getMetaDataFile();
        $this->ev = $this->getEditView();
        $this->ev->ss = & $this->ss;
        $this->ev->setup($this->module, $this->bean, $metadataFile, 'include/EditView/EditView.tpl');
    }

    function display() {

        global $db, $current_user;
        //Get All Reports To Id User of Current User in Array Format
        $ReportsToTeamArray = getReportsToUserArray($current_user->id);
        //Get User Id By Reports To Id from team table
        $AssignedUserIdArray = getUserIdByPrivateTeam($ReportsToTeamArray);

        $js1 = <<<EOF
<script>

                            var restictedUsers='$AssignedUserIdArray';                           
                            if(document.getElementById('EditView')!=null)
                            {
                                var _form = document.getElementById('EditView');
                                var formElements = _form.getElementsByTagName("*"); 
 for(var i=0;i < formElements.length; i++)
                                {
                                      // Check if the value of the current element is Save
                                      if (formElements[i].value == "Save")
                                      {
                                         formElements[i].setAttribute("onclick", "return SetSaveActionEditView()");
                                      }
   }  
                            }
                            function SetSaveActionEditView()
                            {                              
                                var _form = document.getElementById('EditView'); 
                                _form.action.value='Save';                            
                                if(check_form('EditView'))
                                {
  data=eval('('+restictedUsers+')');
                                    if(data.indexOf(_form.assigned_user_id.value) > -1)
                                    {
                                     alert('Not Autorized To Assign Case To Reporting To Person');
                                     return false;
                                    }

                                    SUGAR.ajaxUI.submitForm(_form);
                                    return false;
                                }
                                return false;
</script>
EOF;

        $this->ev->process();
        echo $this->ev->display($this->showTitle);       
        echo $js1;
    }

    /**
     * Get EditView object
     * @return EditView
     */
    protected function getEditView() {
        return new EditView();
    }

}
Advertisements

Get Reports To User in Array Format – Sugar CRM

The Following Function will return the Users Reports To one by one
like category and its parent category concept

/*
$userId is the id of user
$teamArray is the result which will return array of reports to hierarchy
*/

function getReportsToUserArray($userId, $teamArray = array()) {
    if (!empty($userId) && $userId != 1) {
        $reportingUser = new User();
        $reportingUser->retrieve($userId);
        if (!empty($reportingUser->reports_to_id) && $reportingUser->reports_to_id != 1) {
            $teamArray[] = User::staticGetPrivateTeamID($reportingUser->reports_to_id);
            $nextuserId = $reportingUser->reports_to_id;            
            return getReportsToUserArray($nextuserId, $teamArray);
        }
        return $teamArray;
    }
}

How to Add Custom Subpanel in DetailView of Sugar CRM

There comes the time when sales rep finds it irritating to view opportunities Closed Won and Closed Lost under same subpanel.
Lets make custom subpanels separating Closed Won and Closed Lost.
In this blog post, we will add those subpanels under Accounts module.
Step 1 : Create custom/Extension/modules/Accounts/Ext/Layoutdefs/<any_name>.php and write the following code into it.

<?php 
$layout_defs[‘Accounts’][‘subpanel_setup’][‘opp_closed_lost’] =
array(‘order’ => 49,
‘module’ => ‘Opportunities’,
‘subpanel_name’ => ‘ForAccounts’,
‘get_subpanel_data’ => ‘function:get_closed_lost_closed_won_opportunities’,
‘generate_select’ => true,
‘title_key’ => ‘LBL_OPPORTUNITIES_WITH_CLOSED_LOST’,
‘top_buttons’ => array(),
‘function_parameters’ => array(
‘import_function_file’ => ‘custom/modules/Accounts/customOpportunitiesSubpanel.php’,
‘sales_stage’ => ‘Closed Lost’,
‘account_id’ => $this->_focus->id,
‘return_as_array’ => ‘true’
),
);
$layout_defs[‘Accounts’][‘subpanel_setup’][‘opp_closed_won’] =
array(‘order’ => 50,
‘module’ => ‘Opportunities’,
‘subpanel_name’ => ‘ForAccounts’,
‘get_subpanel_data’ => ‘function:get_closed_lost_closed_won_opportunities’,
‘generate_select’ => true,
‘title_key’ => ‘LBL_OPPORTUNITIES_WITH_CLOSED_WON’,
‘top_buttons’ => array(),
‘function_parameters’ => array(
‘import_function_file’ => ‘custom/modules/Accounts/customOpportunitiesSubpanel.php’,
‘sales_stage’ => ‘Closed Won’,
‘account_id’ => $this->_focus->id,
‘return_as_array’ => ‘true’
),
);
?>

Step 2 : Create custom/modules/Accounts/customOpportunitiesSubpanel.php and write following code into it.

<?php 

function get_closed_lost_closed_won_opportunities($params) {
$args = func_get_args();
$opportunitiesSalesStage = $args[0][‘sales_stage’];
$accountId = $args[0][‘account_id’];
$return_array[‘select’] = ” SELECT opportunities.*”;
$return_array[‘from’] = ” FROM opportunities “;
$return_array[‘where’] = ” WHERE opportunities.deleted = ‘0’ AND opportunities.sales_stage = ‘” . $opportunitiesSalesStage . “‘”;
$return_array[‘join’] = ” INNER JOIN accounts_opportunities ON accounts_opportunities.opportunity_id = opportunities.id AND accounts_opportunities.deleted = ‘0’ INNER JOIN accounts ON accounts.id = accounts_opportunities.account_id AND accounts.deleted = ‘0’ AND accounts.id = ‘” . $accountId . “‘”;
$return_array[‘join_tables’] = ”;
return $return_array;
}
?>

Step 3 : Create custom/Extension/modules/Accounts/Ext/Language/en_us.<any_name>.php and write the following custom label into it.

<?php 

$mod_strings[‘LBL_OPPORTUNITIES_WITH_CLOSED_LOST’] = “Opportunities With Closed Lost”;
$mod_strings[‘LBL_OPPORTUNITIES_WITH_CLOSED_WON’] = “Opportunities With Closed Won”;
?>

Step 4 : Do Quick Repair and Rebuild from Admin panel.

Modify SugerField Address – Country dropdown in Sugar CRM

First change the type of country fields Suppose we are changing the address control fields in Leads module. Create one php file and add the code in and put it to custom/extension/modules/Leads/Ext/Vardefs/

Following code will change the primary_address_country field and convert it to dropdown
$dictionary['Lead']['fields']['primary_address_country'] =
        array(
            'name' => 'primary_address_country',
            'vname' => 'LBL_PRIMARY_ADDRESS_COUNTRY',
            'type' => 'enum',
            'options' => 'countries_dom',
            'group' => 'primary_address',
            'comment' => 'Country for primary address',
            'merge_filter' => 'enabled',
);

Following code will change the alt_address_country field and convert it to dropdown
$dictionary['Lead']['fields']['alt_address_country'] =
        array(
            'name' => 'alt_address_country',
            'vname' => 'LBL_ALT_ADDRESS_COUNTRY',
            'type' => 'enum',
            'options' => 'countries_dom',
            'group' => 'alt_address',
            'comment' => 'Country for alternate address',
            'merge_filter' => 'enabled',
);

Note: Similarly we can change the country field for Account,Contacts Module

Now copy include/SugarFields/Fields/Address/en_us.EditView.tplfile and paste as custom/include/SugarFields/Fields/Address/en_us.EditView.tpl And change the type of address_country from input to dropdown and add following code to fetch all contries in dropdown

{if isset($fields.{{$country}}.value) && $fields.{{$country}}.value != ''} {html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.value} {else} {html_options options=$fields.{{$country}}.options selected=$fields.{{$country}}.default_value} {/if}

After making this changes Repair and Rebuild the sugar crm This will add the country dropdown in address Field Now create one dropdown named as countries_dom and add the countries in it The countries added in this dropdown will be shown in country dropdown in address SugarField this dropdown array will be added in custom/include/language/en_us.lang.php like

$GLOBALS['app_list_strings']['countries_dom'] = array(
    "AF" => "Afghanistan",
    "AL" => "Albania",
);

One To Many RelationShip using php Code – Sugar CRM

In Sugar CRM If you want to create one to many relatinship like in studio
then the following steps can be used.

Here there are 12 parts of code.
This will generate the relationship between passed modules and create subpanel of related module under the primary module

The All Parts are used like :
Part 1:
Here Accounts and PMX_ProcessTask are two modules
We are going to create one to many relationship from account to pmx_process task
so in this part two modules are passed in varibales as up $primarymodule & $secondarymodule

Part 2:
The variables created in first part will be used in part 2 and
This part will create the code for relationship file.

Part 3:
This part will format the php code.
Then this part will create the relationship file in custom/metadata directory of sugarcrm
Then this code will be written to relationship file.

Part 4:
This part will create one relationship file in custom/Extension/application/Ext/TableDictionary/
and then add one line of code in this file.

Part 5:
This part will create the php vardef code for primary module.
Then create a vardef file in custom/Extension/primarymodule/Ext/vardefs/.
Then the php code will be written to this file.

Part 6:
This part will create the php vardef code for secodary module.
Then create a vardef file in custom/Extension/secondarymodule/Ext/vardefs/.
Then the php code will be written to this file.

Part 7:
This part will create the code for creating subpanel of secodary module under the primary module.

Part 8:
This part will create one file in custom/Extension/primarymodule/Ext/Layoutdefs/ directory
Then The code generated for subpanel in part 8 will be added in created php file.

Part 9:
This part will create the one file in custom/Extension/primarymodule/Ext/Language/
Then this will add language variable code in this file.

Part 10:
This part will create the one file in custom/Extension/secondarymodule/Ext/Language/
Then this will add language variables code in this file.

Part 11:
This part will make relationship entry in relatinship table of sugarcrm.

Part 12:
All the files and its code is created in this 11 steps one by one.
Now this part will Repair and Rebuild the sugar crm so code will make changes to create the relationship and relationship will be
generated.
Then this part will rebuild the relationship in sugar crm.So the subpanel os secondary module is seen under the Primary Module.

Part 1:

        $obj1 = new $beanList['Accounts']();
        $primarymoduleLower = strtolower($obj1->module_name);
        $primarymoduleUpper = $obj1->module_name;
        $primarymoduletable = $obj1->table_name;
        $obj2 = new $beanList['PMX_ProcessTask']();
        $secondarymoduleLower = strtolower($obj2->module_name);
        $secondarymoduleUpper = $obj2->module_name;
        $secondarymoduletable = $obj2->table_name;
        $relationshipName = $primarymoduleLower . "_" . $secondarymoduleLower;
        $relationshipNameQuoted = "'" . $relationshipName . "'";

Part 2:

        $relarray = array(
            "'true_relationship_type'" => "'one-to-many',",
            "'from_studio'" => true,
            ",'relationships'" =>
            array(
                "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "'" =>
                array(
                    "'lhs_module'" => "'" . $primarymoduleUpper . "',",
                    "'lhs_table'" => "'" . $primarymoduletable . "',",
                    "'lhs_key'" => "'id',",
                    "'rhs_module'" => "'" . $secondarymoduleUpper . "',",
                    "'rhs_table'" => "'" . $secondarymoduletable . "',",
                    "'rhs_key'" => "'id',",
                    "'relationship_type'" => "'many-to-many',",
                    "'join_table'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "',",
                    "'join_key_lhs'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $primarymoduleLower . "_ida',",
                    "'join_key_rhs'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $secondarymoduleLower . "_idb'",
                ),
            ),
            "'table'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "',",
            "'fields'" =>
            array(
                0 =>
                array(
                    "'name'" => "'id',",
                    "'type'" => "'varchar',",
                    "'len'" => 36,
                ),
                1 =>
                array(
                    "'name'" => "'date_modified',",
                    "'type'" => "'datetime'",
                ),
                2 =>
                array(
                    "'name'" => "'deleted',",
                    "'type'" => "'bool',",
                    "'len'" => "'1',",
                    "'default'" => "'0',",
                    "'required'" => true,
                ),
                3 =>
                array(
                    "'name'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $primarymoduleLower . "_ida',",
                    "'type'" => "'varchar',",
                    "'len'" => 36,
                ),
                4 =>
                array(
                    "'name'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $secondarymoduleLower . "_idb',",
                    "'type'" => "'varchar',",
                    "'len'" => 36,
                ),
            ),
            "'indices'" =>
            array(
                0 =>
                array(
                    "'name'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "spk',",
                    "'type'" => "'primary',",
                    "'fields'" =>
                    array(
                        0 => "'id'",
                    ),
                ),
                1 =>
                array(
                    "'name'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "_ida1',",
                    "'type'" => "'index',",
                    "'fields'" =>
                    array(
                        0 => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $primarymoduleLower . "_ida'",
                    ),
                ),
                2 =>
                array(
                    "'name'" => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . "_alt',",
                    "'type'" => "'alternate_key',",
                    "'fields'" =>
                    array(
                        0 => "'" . $primarymoduleLower . "_" . $secondarymoduleLower . $secondarymoduleLower . "_idb'",
                    ),
                ),
            ),
        );

Part 3:
copy the array in txt file and remove [ and ] start

        $ftext = fopen('test.txt', 'w');
        fwrite($ftext, print_r($relarray, true));
        $metadataString = file_get_contents('test.txt');
        $metadataString = str_replace('[', '', $metadataString);
        $metadataString = str_replace(']', '', $metadataString);
        $metadataString = str_replace(')', '),', $metadataString);
        $metadataStringToArray = substr(trim($metadataString), 0, -1);
        fclose($ftext);
       //copy the array in txt file and remove [ and ] End
        $metadataFilename = $relationshipName . "MetaData.php";

        $metadataString = "<?php $" . "dictionary[$relationshipNameQuoted]=";
        $RelationshipMetadataFile = fopen('custom/metadata/' . $metadataFilename, 'w');
        fwrite($RelationshipMetadataFile, $metadataString);
        fwrite($RelationshipMetadataFile, $metadataStringToArray);
        fwrite($RelationshipMetadataFile, ";");
        fclose($RelationshipMetadataFile);

Part 4:
Add the metadata file include string to tabledictionary start

        $tabledictionaryFileName = $relationshipName . ".php";
        $RelationshipMetadataFile = fopen('custom/Extension/application/Ext/TableDictionary/' . $tabledictionaryFileName, 'w');
        fwrite($RelationshipMetadataFile, " ");
        fclose($RelationshipMetadataFile);

Part 5:
Primary module vardef file generation Start

        $primaryModulevardefString = " '" . $relationshipName . "',
  'type' => 'link',
  'relationship' => '" . $relationshipName . "',
  'source' => 'non-db',
  'side' => 'right',
  'vname' => 'LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($secondarymoduleUpper) . "_TITLE',
);";

        $primarymodulevardefFile = 'custom/Extension/modules/' . $primarymoduleUpper . '/Ext/Vardefs/' . $relationshipName . '_' . $primarymoduleUpper . '.php';
        $primarymodulevardefFile = fopen($primarymodulevardefFile, 'w');
        fwrite($primarymodulevardefFile, $primaryModulevardefString);
        fclose($primarymodulevardefFile);

Part 6:
Secondary module vardef file generation Start

        $vardefStringSecondaryModule = " '" . $relationshipName . "',
  'type' => 'link',
  'relationship' => '" . $relationshipName . "',
  'source' => 'non-db',
  'vname' => 'LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($primarymoduleUpper) . "_TITLE',
  'id_name' => '" . $relationshipName . $primarymoduleLower . "_ida',
);";


        $vardefStringSecondaryModule.='$dictionary["' . $beanList[$secondarymoduleUpper] . '"]["fields"]["' . $relationshipName . '_name"] = ';
        $vardefStringSecondaryModule .="array (
  'name' => '" . $relationshipName . "_name',
  'type' => 'relate',
  'source' => 'non-db',
  'vname' => 'LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($primarymoduleUpper) . "_TITLE',
  'save' => true,
  'id_name' => '" . $relationshipName . $primarymoduleLower . "_ida',
  'link' => '" . $relationshipName . "',
  'table' => '" . $primarymoduletable . "',
  'module' => '" . $primarymoduleUpper . "',
  'rname' => 'name',
);";

        $vardefStringSecondaryModule.='$dictionary["' . $beanList[$secondarymoduleUpper] . '"]["fields"]["' . $relationshipName . $primarymoduleLower . '_ida"] = ';
        $vardefStringSecondaryModule.="array (
  'name' => '" . $relationshipName . $primarymoduleLower . "_ida',
  'type' => 'link',
  'relationship' => '" . $relationshipName . "',
  'source' => 'non-db',
  'reportable' => false,
  'side' => 'right',
  'vname' => 'LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($secondarymoduleUpper) . "_TITLE',
);";

//Secondary module vardef file generation Start

        $secondarymodulevardefFile = 'custom/Extension/modules/' . $secondarymoduleUpper . '/Ext/Vardefs/' . $relationshipName . '_' . $secondarymoduleUpper . '.php';
        $secondarymodulevardefFile = fopen($secondarymodulevardefFile, 'w');
        fwrite($secondarymodulevardefFile, $vardefStringSecondaryModule);
        fclose($secondarymodulevardefFile);

Part 7:
subpanel under the primary module start

        $primaryModuleSubpanelString = " 100,
  'module' => '" . $secondarymoduleUpper . "',
  'subpanel_name' => 'default',
  'sort_order' => 'asc',
  'sort_by' => 'id',
  'title_key' => 'LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($secondarymoduleUpper) . "_TITLE',
  'get_subpanel_data' => '" . $relationshipName . "',
  'top_buttons' => 
  array (
    0 => 
    array (
      'widget_class' => 'SubPanelTopButtonQuickCreate',
    ),
    1 => 
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',
    ),
  ),
);";

Part 8:

        $primarymoduleLayoutdefsFile = 'custom/Extension/modules/' . $primarymoduleUpper . '/Ext/Layoutdefs/' . $relationshipName . '_' . $primarymoduleUpper . '.php';
        $primarymoduleLayoutdefsFile = fopen($primarymoduleLayoutdefsFile, 'w');
        fwrite($primarymoduleLayoutdefsFile, $primaryModuleSubpanelString);
        fclose($primarymoduleLayoutdefsFile);

Part 9:
Primary module langugar file start

        $primaryymoduleLanguageFile = 'custom/Extension/modules/' . $primarymoduleUpper . '/Ext/Language/en_us.custom' . $relationshipName . '.php';
        $primaryymoduleLanguageFile = fopen($primaryymoduleLanguageFile, 'w');
        fwrite($primaryymoduleLanguageFile, "<?php ");
        $languagestring1 = "$" . "mod_strings['LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($secondarymoduleUpper) . "_TITLE'] = '" . $secondarymoduleUpper . "';";
        fwrite($primaryymoduleLanguageFile, $languagestring1);
        fclose($primaryymoduleLanguageFile);

Part 10:
Secondary module langugar file start

        $secondarymoduleLanguageFile = 'custom/Extension/modules/' . $secondarymoduleUpper . '/Ext/Language/en_us.custom' . $relationshipName . '.php';
        $secondarymoduleLanguageFile = fopen($secondarymoduleLanguageFile, 'w');
        fwrite($secondarymoduleLanguageFile, "<?php ");
        $languagestring2 = "$" . "mod_strings['LBL_" . strtoupper($relationshipName) . "_FROM_" . strtoupper($primarymoduleUpper) . "_TITLE'] = '" . $primarymoduleUpper . "';";
        fwrite($secondarymoduleLanguageFile, $languagestring2);
        fclose($secondarymoduleLanguageFile);
     

Part 11:
Insert the record in the relationship table Start

  $rid = create_guid();
        $ida = $primarymoduleLower . "_" . $secondarymoduleLower . $primarymoduleLower . "_ida";
        $idb = $primarymoduleLower . "_" . $secondarymoduleLower . $secondarymoduleLower . "_idb";
        $relatioshipQueary = "INSERT INTO `relationships`
(`id`, `relationship_name`, `lhs_module`, `lhs_table`, `lhs_key`, `rhs_module`, `rhs_table`, `rhs_key`, `join_table`, `join_key_lhs`, `join_key_rhs`, `relationship_type`, `relationship_role_column`, `relationship_role_column_value`, `reverse`, `deleted`)
VALUES('$rid', '$relationshipName', '$primarymoduleUpper', '$primarymoduleLower', 'id', '$secondarymoduleUpper', '$secondarymoduleLower', 'id', '$relationshipName', '$ida', '$idb', 'many-to-many', NULL, NULL, 0, 0)";
        $db->query($relatioshipQueary);

Part 12:
Repair and Rebuild Relationship after all files are added Start

        require_once("modules/Administration/QuickRepairAndRebuild.php");
        $rac = new RepairAndClear();
        $rac->repairAndClearAll(array('clearAll'), $moduleList, true, false);
        $mod_strings = array_merge($mod_strings, return_module_language('en_us', 'Administration'));
        include('modules/Administration/RebuildRelationship.php');

Get All Related Record – Sugar CRM

Here assume that there are two modules Leads and Bhea_Lead_Contact
First create the relationship one to many from leads to Bhea_Lead_Contact

Suppose lead id is 34eb9639-4c23-fb6d-dc30-50bc8c8e420f
The relationship between both module is leads_bhea_lead_contact

The following code will be used to all Bhea_Lead_Contact records which are related to specific lead

require_once(‘modules/Leads/Lead.php’);
$ld = new Lead();
$ld->retrieve(’34eb9639-4c23-fb6d-dc30-50bc8c8e420f’);
$ld->load_relationship(‘leads_bhea_lead_contact_1’);
$RetrievedLeadContacts = $ld->leads_bhea_lead_contact_1->getBeans();

print_r($RetrievedLeadContacts);

Above code will print all lead contacts

if we want to add record in subpanel using code than
Suppose Bhea_Lead_Contactid is 93b6b83b-b2de-a665-ab99-50c84f407a7e
try the following code

require_once(‘modules/Leads/Lead.php’);
$ld = new Lead();
$ld->retrieve(’34eb9639-4c23-fb6d-dc30-50bc8c8e420f’);
$ld->load_relationship(‘leads_bhea_lead_contact_1′);
$ld->leads_bhea_lead_contact_1->add(’93b6b83b-b2de-a665-ab99-50c84f407a7e’);

Note: If the relationship is between sugar default module then we have to pass the link filed name in load_relationship() function
because sugar crm internally takes filed defs name value
for example if we are adding contacts under the account module
then the relationship is accounts_contacts But we have to pass ‘contacts’ in load_relationship function

Add Fields to Basic Search in List View of Module – Sugar CRM

Here assume that we are going to add Datepicker in the Basic search panel on Case Module List view.

===========================================================

create the fileSearchFields.php at the custom/modules/Cases/metadata/
and add the following code to this file

$searchFields[‘Cases’] =

array(
’email_notification_date’ => array(
‘query_type’ => ‘default’,
‘operator’ => ‘subquery’,
‘subquery’ => ‘SELECT parent_id FROM emails WHERE emails.deleted=0 AND emails.date_entered LIKE’,
‘is_date_field’ => true,
‘db_field’ => array(
‘id’,
)
),
);

===============================================================

copy the searchdefs.php file from modules/Cases/metadata/
and paste it to custom/ modules/Cases/metadata/
and add the following key value array to last in the ‘basic_search’ array

‘open_only’ => array(
‘name’ => ’email_notification_date’,
‘label’ => ‘LBL_EMAIL_NOTIFICATION_ON_DATE’,
‘type’ => ‘datetime’,
‘default’ => true,
‘width’ => ‘10%’,
),

//added by hiren prajapati End

===============================================================

create the file en_us.customcases_email.php at custom/Extension/modules/Cases/Ext/Language/

and add the following code to it

$mod_strings[‘LBL_EMAIL_NOTIFICATION_ON_DATE’] = ‘Notification Received On Date:’;

This label is used as label in basic search

==============================================================

Quick repair and Rebuild is required after making this changes
After making this changes go to case list view.
Notification Received On DatePicker will be shown in basic search Panel.
When selecting date from this and press search button,It will result the rows in case list view. this rows will be all the rows
which have email received on the selected date.