Custom enum field in relationship table


I’ve successfully implemented (with plenty of pain) a custom enum field in a relationship table by using this tutorial:

The relationship is a N-N-relationship and the custom field is shown in both modules in a subpanel. From there it’s also possible to edit the field by clicking on the “Edit”-button. This all works fine, the only issue is that in the subpanels the field-name is not correctly shown. It doesn’t show the value from the “list-dictionary” that is defined in \custom\include\language\en_us.lang.php, e.g.:

$GLOBALS['app_list_strings']['modulename_customfield_list'] = array(
    'market' => 'Market', 
    'competitors' => 'Competitors', 
    'financial_state' => 'Financial State', 

It rather shows the raw value that’s also in the database. I think I have correctly set this up in the file \custom\metadata\relationship_nameMetaData.php:

array (
‘name’ => ‘customfield’,
‘type’ => ‘enum’,
‘options’ => ‘modulename_customfield_list’

however it’s not using that in the subpanel:


Does anybody know how to use the list names array in the subpanels?


Hi, You must set this :

array (
‘name’ => ‘customfield’,
‘type’ => ‘enum’,
‘options’ => ‘modulename_customfield_list’

insert in your customClass in var var $field_defs = array ().
important check set there ‘options’ => ‘modulename_customfield_list’.

Sorry for my bad english.


Thanks for you answer. I checked that before and now checked it again but unfortunately it doesn’t make any difference…

I’m curious, where did you get that 22-page tutorial from?

About your current issue: maybe you can try with some customCode, like here:

I’ve got the tutorial from this page.

Apparently customCode cannot be applied to subpanels, according to this post:

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(
     '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):

$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.

1 Like

Excellent post, thanks. Very helpful.

I made some edits to your mark-up (to get syntax highighting): click the pencil icon near the top of your post, then click Raw to learn how it’s done)


1 Like