AnsweredAssumed Answered

How do you search by a related cstm field?

Question asked by gperez gperez on May 9, 2014
Latest reply on May 9, 2014 by gperez gperez
I have a relation between A and B. And I'm able to search in A list filtering by "B.name" field, let's say. But I just cant figure out how to filter by B's custom fields. By example, "B.description_c".

That custom field exists in _cstm table. So I tried code similar to this one (the one that retrieves B.name): 

$dictionary["oasis_Reservations"]["fields"]["ress5_resels_reservations"] = array (  'name' => 'ress5_resels_reservations',
  'type' => 'link',
  'relationship' => 'ress5_resellers_oasis_reservations',
  'source' => 'non-db',
  'vname' => 'LBL_RESS5_RESELLERS_OASIS_RESERVATIONS_FROM_RESS5_RESELLERS_TITLE',
);
$dictionary["oasis_Reservations"]["fields"]["ress5_reselervations_name"] = array (
  'name' => 'ress5_reselervations_name',
  'type' => 'relate',
  'source' => 'non-db',
  'vname' => 'LBL_RESS5_RESELLERS_OASIS_RESERVATIONS_FROM_RESS5_RESELLERS_TITLE',
  'save' => true,
  'id_name' => 'ress5_resef6f8sellers_ida',
  'link' => 'ress5_resels_reservations',
  'table' => 'ress5_resellers',
  'module' => 'ress5_Resellers',
  'rname' => 'name',
);
$dictionary["oasis_Reservations"]["fields"]["ress5_resef6f8sellers_ida"] = array (
  'name' => 'ress5_resef6f8sellers_ida',
  'type' => 'link',
  'relationship' => 'ress5_resellers_oasis_reservations',
  'source' => 'non-db',
  'reportable' => false,
  'side' => 'right',
  'vname' => 'LBL_RESS5_RESELLERS_OASIS_RESERVATIONS_FROM_OASIS_RESERVATIONS_TITLE',
);

That approach can't retrieve results, because even when I declare that the linked table has an id named "id_c", Sugar will ALWAYS force the join to have an id named "id". (Don't remember right now if that logic is hardcoded in Link.php or in SugarBean.php but I'm 100% sure). 


My sugar version in 6.2

Any help will be much appreciated. 

Outcomes