Question

I have created a calculated field, in my vardefs the field is non-db, sortable and type varchar. I have a logic hooks on retrieve and a function with the calculation, works like a charm in edit and list view. But when I click on the column name calculated field (listview) the query return 0 records.

I tried several things with no success, I'm missing something.

the query when I click on the calculated column (field = 'difference_c'):

SELECT aos_quotes.id , aos_quotes.number , aos_quotes.name , aos_quotes.stage , aos_quotes.billing_contact_id, LTRIM(RTRIM(CONCAT(IFNULL(jt0.first_name,''),' ',IFNULL(jt0.last_name,'')))) billing_contact , aos_quotes.billing_account_id, jt1.name billing_account , aos_quotes.total_amount , aos_quotes.currency_id , aos_quotes.expiration , LTRIM(RTRIM(CONCAT(IFNULL(jt2.first_name,''),' ',IFNULL(jt2.last_name,'')))) assigned_user_name , jt2.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod, aos_quotes.date_entered , aos_quotes.enddate_c , aos_quotes.startdate_c , aos_quotes.assigned_user_id FROM aos_quotes LEFT JOIN contacts jt0 ON aos_quotes.billing_contact_id = jt0.id AND jt0.deleted=0 LEFT JOIN accounts jt1 ON aos_quotes.billing_account_id = jt1.id AND jt1.deleted=0 LEFT JOIN users jt2 ON aos_quotes.assigned_user_id=jt2.id AND jt2.deleted=0 AND jt2.deleted=0 where aos_quotes.deleted=0 ORDER BY difference_c ASC
Was it helpful?

Solution

Unfortunately you can NOT order ListView records by non-db field. To disallow users to do so, you should set 'sortable' key to false in field definition in listviewdefs.php files like:

'MY_CUSTOM_NON-DB_FIELD' => 
  array (
    'type' => 'char',
    'label' => 'LBL_MY_CUSTOM_NON-DB_FIELD',
    'width' => '15%',
    'sortable' => false,
  ),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top