I’ve got the tutorial from this page.
Apparently customCode cannot be applied to subpanels, according to this post: https://community.suitecrm.com/t/customize-subpanel-display/24404
So I had to create two logic hooks (for both subpanels). This is how I did it:
a) Add to \modules\MODULEA\MODULEAListViewLogicHooks.php
and \modules\MODULEB\MODULEBListViewLogicHooks.php
:
public function getCUSTOMFIELDLabel(SugarBean $bean , $event , $arguments )
{
if (! is_null ( $bean ->RELNAME_CUSTOMFIELD) && $bean ->RELNAME_CUSTOMFIELD != '' ) {
$bean ->CUSTOMFIELD_label = $GLOBALS [ 'app_list_strings' ][ 'modulename_customfield_list' ][ $bean ->RELNAME_CUSTOMFIELD];
}
}
b) Add to \custom\Extension\modules\MODULEA\Ext\LogicHooks\LogicHooks.php and \custom\Extension\modules\MODULEB\Ext\LogicHooks\LogicHooks.php:
$hook_array [ 'process_record' ][] = Array(
8,
'add label to custom relationship field' ,
'modules/MODULEA/MODULEAListViewLogicHooks.php' ,
'MODULEAListViewLogicHooks' ,
'getCUSTOMFIELDLabel' ,
);
Create file if it doesn’t exist; look at other files to replicate structure.
Accordingly replace MODULEA with MODULEB and adjust the index (in this example 8).
c) Create non_db fields by creating files: \custom\Extension\modules\MODULEA\Ext\Vardefs\sugarfield_CUSTOMFIELD_label.php
(the same for MODULEB):
<?php
$dictionary [ "MODULEA" ][ "fields" ][ "CUSTOMFIELD_label" ] = array (
'name' => 'CUSTOMFIELD_label' ,
'type' => 'varchar' ,
'default' => '' ,
'vname' => 'LBL_SOME_LABEL' ,
'reportable' =>true,
'source' => 'non-db' ,
);
Adjust the vname.
d) add column to subpanels in: \custom\modules\MODULEA\metadata\subpanels\ForMODULEB.php
:
'CUSTOMFIELD_label' => array (
'name' => 'CUSTOMFIELD_label' ,
'vname' => 'LBL_SOME_LABEL' ,
'width' => '10%' ,
'sortable' =>false,
),
adjust vname and delete the other column. Do the same for the other subpanel.