How to set flag in get_entry_list API to know if case is added as favorite or not in suiteCRM?

I am working on suiteCRM API, especially on get_entry_list() which is responsible to return list of cases.

I found that, it contains favorite parameter but returns list of all the favorite cases only.

I found that SugarBean::create_new_list_query() function is responsible for generating final query for the data to be fetched.

So, I added this condition (in my case)-

if($condition) {
    $ret_array['select'] .= ',favorites.parent_id as is_favorite_case';
    $ret_array['from'] .= 'LEFT JOIN favorites on cases.id=favorites.parent_id';
}

Then, this raw query is passed to SugarBean::process_list_query() to get the final result. But I am stuck at

foreach($this->field_defs as $field=>$value)
{...}

$this->field_defs how to set this new column is_favorite_case in it so that I would be able to add that in the response?

I think those field_defs are simply the vardefs for that module. So if you extend the vardefs adding that field, it should appear there.

Try adding it like this (example if for Leads module, change it to Cases):

custom/Extension/modules/Leads/Ext/Vardefs/AddVardef.php

<?php

$dictionary['Lead']['fields']['description']['your_new_key']  = 'some text';

?>

I am not sure how that will play out with the API though, never tried it. Tell us if it works!

Thanks. I solve that problem with similar way as you suggested like this-

added new variable in modules\Cases\Case.php as $is_favorite_Case &

in modules\Cases\vardefs.php I added

 'is_favorite_case' =>
  array (
    'name' => 'is_favorite_case',
    'source'=>'non-db',
    'type'=>'bool',
    'len' => 1,
    'importable' => 'false',
    'studio' => array("formula" => false),
  ),

That is not upgrade-safe. If you use the proper extension mechanisms it’s better.