Sort Activities (Tasks) Subpanel by Custom Field

I successfully copied the ForActivites.php file for Tasks to custom and added a custom field.

However, I cannot see how to make the panel default to sorting by the custom field.

In modules/Cases/metadata I found subpaneldefs.php

I changed:

‘activities’ => array( ‘order’ => 10,
‘sort_order’ => ‘asc’,
‘sort_by’ => ‘name’,

to

‘activities’ => array( ‘order’ => 10,
‘sort_order’ => ‘asc’,
‘sort_by’ => ‘wf_order_c’,

However that doesn’t work. It seems you can’t use this file to sort by custom field.

The other thing strange is, isn’t modifying this subpaneldefs.php NOT upgrade safe, yet if you copy to same place in custom folder changes do not have any effect?

If anyone or you still need the answer. Go to

custom/Extension/modules/Leads/Ext/Layoutdefs/YOUR_SUBPANEL_RELATIONSHIP_NAME.php

and edit
sort order and sort by


'order' => 100,
  'module' => 'pipe_Payments',
  'subpanel_name' => 'default',
  'sort_order' => 'asc',
  'sort_by' => 'payment_date',
  'title_key' => 'LBL_LEADS_PIPE_PAYMENTS_1_FROM_PIPE_PAYMENTS_TITLE',
  'get_subpanel_data' => 'leads_pipe_payments_1',
  'top_buttons' => 

Do a quick repair and rebuild and you are done.