@pgr @Pablonr Thank you, The issue is resolved. Initially, I had created a relationship for adding the subpanel, which was unnecessary. I made changes in these three files.
created new file:
public/custom/Extension/modules/Accounts/Ext/Layoutdefs/services_custom_subpanel.php
<?php
// created: 2024-02-15 08:34:23
$layout_defs["Accounts"]["subpanel_setup"]['custom_service_subpanel'] = array(
'order' => 100,
'module' => 'j_Services',
'subpanel_name' => 'ForAccounts',
'title_key' => 'LBL_SERVICES_CUSTOM_SUBPANEL_FOR_ACCOUNTS',
'get_subpanel_data' => 'function:getRelatedServiceQueryData',
'generate_select' => true,
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/Accounts/GetRelatedServiceQueryData.php',
'accountId' => $this->_focus->id,
'return_as_array' => 'true'
),
);
public/custom/modules/Accounts/GetRelatedServiceQueryData.php
<?php
/**
* Function : getRelatedServiceQueryData
* This function is for creating the query for fetching data in service subpannel in accounts
* @return <Array>
*/
function getRelatedServiceQueryData($param)
{
global $app;
$controller = $app->controller;
$bean = $controller->bean;
$return_array['select'] = " SELECT j_services.id ,j_services.name,round(j_services.minimum_fee,2) AS 'minimum_fee',j_services.date_entered,j_services.date_modified, j_services_cstm.agency_c, j_services_cstm.years_c,j_services_cstm.service_category_c,leads.id AS 'LeadID',j_services_cstm.status_c,j_services_cstm.date_completed_c,j_services_cstm.date_cancelled_c ";
$return_array['from'] = " FROM j_services ";
$return_array['where'] = " j_services.deleted=0 AND leads.account_id='" . $bean->id . "' ";
$return_array['join'] = " INNER JOIN leads_j_services_1_c ON leads_j_services_1_c.leads_j_services_1j_services_idb = j_services.id AND leads_j_services_1_c.deleted=0
LEFT JOIN leads ON leads.id = leads_j_services_1_c.leads_j_services_1leads_ida AND leads.deleted=0 ";
$return_array['join_tables'] = '';
return $return_array;
}
public/custom/modules/j_Services/metadata/subpanels/ForAccounts.php
<?php
// created: 2024-02-15 09:08:26
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
$module_name = 'j_Services';
$subpanel_layout = array(
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => $module_name),
),
'where' => '',
'list_fields' => array of list fields
);