Subpanel with custom Query

Hi, i want create a subpanel with my own Query to read some field on my Query.

here my code

$layout_defs['Leads']['subpanel_setup']['get_mobile_duplicate'] =
        array('order' => 40,
            'module' => 'Leads',
            'subpanel_name' => 'Lead_subpanel_get_mobile_duplicate',
            'get_subpanel_data' => 'function:get_mobile_duplicate',
            'generate_select' => true,
            'title_key' => 'List Duplicate',
            'top_buttons' => array(),
            'function_parameters' => array(
                'import_function_file' => 'custom/modules/Leads/customFindLeadsDuplicate.php',
                'id' => $this->_focus->id,
                'phone_mobile' => $this->_focus->phone_mobile,
                'email' => $this->_focus->email1,
                'nric' => $this->_focus->nric_c,
                'return_as_array' => 'true'

function get_mobile_duplicate($params) {
  $args = func_get_args();
  $LeadsId = $args[0]['id'];
  $LeadsMobile = $args[0]['phone_mobile'];
  $LeadsEmail = $args[0]['email'];
  $LeadsNRIC = $args[0]['nric'];
  $return_array['select'] = " select Leads.*, CASE WHEN leads.phone_mobile='$LeadsMobile' THEN 'Mobile Duplicate' WHEN v2.nric_c='$LeadsNRIC' THEN 'NRIC Duplicate' WHEN  vemail_d.email_address = '$LeadsEmail' THEN 'Email Duplicate' ELSE '' END AS duplicate_list ";
  $return_array['from'] = " FROM Leads ";
  $return_array['where'] = " WHERE != '$LeadsId' AND (leads.phone_mobile='$LeadsMobile' OR v2.nric_c='$LeadsNRIC' OR vemail_d.email_address = '$LeadsEmail') ";
  $return_array['join'] = " LEFT JOIN Leads_cstm v2 ON = v2.id_c LEFT JOIN email_addr_bean_rel vemail ON vemail.bean_id = LEFT JOIN email_addresses vemail_d ON vemail.email_address_id = ";
  $return_array['join_tables'] = '';
  return $return_array;

I was hope to list out the duplicate_list in my table. Anyone know how to do it?

Hi, welcome.

Where exactly are you putting those files?

And what is the problem you’re facing? You don’t explain what is missing or broken…

The setup looks fine from the initial glance, you would need to look in the log to see the full query and try to execute it on your end to see the result.

For those new to this concept here’s a video explanation of how this works