AnsweredAssumed Answered

run search many to many relation

Question asked by jlabuelo on Sep 19, 2017
Latest reply on Oct 2, 2017 by jlabuelo

Hello all

 

We have a custom module "ActivitiesFHOM" which is related to Contacts in a many to many relationship.

We would like to allow the user to run a search in the Contacts Search View of all the contacts related to a given ActivityFHOM.

 

We have tried to folow the post where this is explained in:

 

Adding Many to Many Relationships to the Search Box in SuiteCRM and SugarCRM CE 6.5.x | 

 

but we get this error message in our Contacts list view as soon as we go in there:

 

Fatal error: Smarty error: [in cache/modules/Contacts/SearchForm_basic.tpl line 262]: syntax error: unrecognized tag: $fields..name (Smarty_Compiler.class.php, line 434) in /opt/lampp/htdocs/CRM/include/Smarty/Smarty.class.php on line 1095

 

Let me explain you what we have tried to do to see if you think we have missunderstood any step

 

a) first we edited the custom/Extension/modules/Contacts/Ext/Vardefs/vardefs.ext.php by adding

 

/********************************************************************************************************/
$dictionary["Contact"]["fields"]["contacts_oms3_actividades_fhome_1"] = array (
'name' => 'contacts_oms3_actividades_fhome_1',
'type' => 'relate',
'source' => 'non-db',
'module' => 'OMS3_Actividades_FHOME',
'vname' => 'LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1',
'studio' => 'visible',
'id_name' => 'contacts_oms3_actividades_1_id',
);

$dictionary["Contact"]["fields"]["contacts_oms3_actividades_fhome_1_id"] = array (
'name' => 'contacts_oms3_actividades_fhome_1_id',
'type' => 'id',
'source' => 'non-db',
'module' => 'OMS3_Actividades_FHOME',
'vname' => 'LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1',
'studio' => 'visible',
);

$dictionary["Contact"]["fields"]["contacts_oms3_actividades_fhome_1contacts_ida"] = array (
'name' => 'contacts_oms3_actividades_fhome_1contacts_ida',
'type' => 'link',
'source' => 'non-db',
'reportable' => false,
'module' => 'OMS3_Actividades_FHOME',
'side' => 'right',
'vname' => 'LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1_ID_TITLE',
);
/********************************************************************************************************/

2) Then we have added our custom field to SearchDefs in custom/modules/Contacts/metadata/searchdefs.php

'contacts_oms3_actividades_fhome_1_name' =>
array(
'type' => 'relate',
'link' => true,
'label' => 'LBL_CONTACTS_OMS3_ACTIVIDADES_TITLE_1',
'width' => '10%',
'default' => true,
'id' => 'CONTACTS_OMS3_ACTIVIDADES_FHOME_1_IDA',
'name' => 'contacts_oms3_actividades_fhome_1_name',
),

3) We have added our   sub-query to the SearchFields.php in custom/modules/Contacts/metadata/SearchFields.php

'contacts_oms3_actividades_fhome_1' =>
array(
'query_type' => 'default',
'operator' => 'subquery',
'subquery' => 'SELECT CCAA.contacts_oms3_actividades_fhome_1contacts_ida
FROM contacts_oms3_actividades_fhome_1_c CCAA
LEFT JOIN oms3_actividades_fhome AA
ON CCAA.contacts_oms3_actividades_fhome_1oms3_actividades_fhome_idb = AA.id
WHERE AA.deleted =0 AND CCAA.deleted =0 AND AA.name LIKE',
'db_field' =>
array(
0 => 'id',
),
),
);

Then we added the value of LBL_CONTACTS_OMS3_ACTIVIDADES_TITLE_1, and LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1_ID_TITLE in the language file in custom/modules/Contacts/language/es_es.lang.php

'LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1' => 'Actividad Relacionada',
'LBL_CONTACTS_OMS3_ACTIVIDADES_FHOME_1_ID_TITLE' => 'Actividad Relacionada',

Then we can see the field in the Studio->Search edit panel, and we can "make it public". (However the label does not get translated even if we delete the cache).

 

When we click in Repair and Rebuild, if we go to the Contacts screen we can see the error message I showed to you before

Any suggestions about what could be doing wrong please?

 

We are using SugarCRM CE v6.5.24

 

Thanks a lot

Outcomes