Adding a new field in events contact subpanel

Hi gents

I am currently customizing the events module and want to add a “send invitation to test users” like in the campaing module.

I did the 3 steps in the following guide: sugarcrm - In SuiteCRM how to add custom field in sub panel from relationship table? - Stack Overflow

Since I am adding “only” a new field “testrecord” to the db-tables “fp_events_contacts_c”, “fp_events_leads_1_c” and “fp_events_prospects_1_c”, I slightly modified the code.

The issue is as following: I can see the new field in the subpanel (see screenshot), but the data are not populated from the DB. I checked the DB and updated the records manually, but still no luck.

What I did so far:

  1. I created the file “fp_events_contactsMetaData.php” in “custom/metadata” with the following code (see array 8 “testrecord”):
<?php
// created: 2013-03-22 16:34:19
$dictionary["fp_events_contacts"] = array(
  'true_relationship_type' => 'many-to-many',
  'relationships' =>
  array(
    'fp_events_contacts' =>
    array(
      'lhs_module' => 'FP_events',
      'lhs_table' => 'fp_events',
      'lhs_key' => 'id',
      'rhs_module' => 'Contacts',
      'rhs_table' => 'contacts',
      'rhs_key' => 'id',
      'relationship_type' => 'many-to-many',
      'join_table' => 'fp_events_contacts_c',
      'join_key_lhs' => 'fp_events_contactsfp_events_ida',
      'join_key_rhs' => 'fp_events_contactscontacts_idb',
    ),
  ),
  'table' => 'fp_events_contacts_c',
  'fields' =>
  array(
    0 =>
    array(
      'name' => 'id',
      'type' => 'varchar',
      'len' => 36,
    ),
    1 =>
    array(
      'name' => 'date_modified',
      'type' => 'datetime',
    ),
    2 =>
    array(
      'name' => 'deleted',
      'type' => 'bool',
      'len' => '1',
      'default' => '0',
      'required' => true,
    ),
    3 =>
    array(
      'name' => 'fp_events_contactsfp_events_ida',
      'type' => 'varchar',
      'len' => 36,
    ),
    4 =>
    array(
      'name' => 'fp_events_contactscontacts_idb',
      'type' => 'varchar',
      'len' => 36,
    ),
    5 =>
    array(
      'name' => 'invite_status',
      'type' => 'varchar',
      'len'=>'25',
      'default'=>'Not Invited',
    ),
    6 =>
    array(
      'name' => 'accept_status',
      'type' => 'varchar',
      'len'=>'25',
      'default'=>'No Response',
    ),
    7 =>
    array(
      'name' => 'email_responded',
      'type' => 'int',
      'len' => '2',
      'default' => '0',
    ),
    8 =>
    array(
      'name' => 'testrecord',
      'type' => 'bool',
      'len' => '1',
      'default' => '0',
    ),
  ),
  'indices' =>
  array(
    0 =>
    array(
      'name' => 'fp_events_contactsspk',
      'type' => 'primary',
      'fields' =>
      array(
        0 => 'id',
      ),
    ),
    1 =>
    array(
      'name' => 'fp_events_contacts_alt',
      'type' => 'alternate_key',
      'fields' =>
      array(
        0 => 'fp_events_contactsfp_events_ida',
        1 => 'fp_events_contactscontacts_idb',
      ),
    ),
  ),
);

I repeated it for leads and prospects too. After a Quick Repair & Restore AND executing the SQL query, I verified the new field in the DB useing PHPmyAdmin. Check!

  1. Then I added the file “_override_event_testrecord.php” in “custom/Extension/modules/Contacts/Ext/Vardefs” with the following code:
<?php

$dictionary['Contacts']['table'] = 'fp_events_contacts_c';
$dictionary['Contacts']['fields']['testrecord']['massupdate'] = false;
$dictionary['Contacts']['fields']['testrecord']['name'] = 'testrecrod';
$dictionary['Contacts']['fields']['testrecord']['type'] = 'bool';
$dictionary['Contacts']['fields']['testrecord']['studio'] = false;
// $dictionary['Contacts']['fields']['testrecord']['source'] = 'non-db';
$dictionary['Contacts']['fields']['testrecord']['vname'] = 'LBL_TESTRECORD';
$dictionary['Contacts']['fields']['testrecord']['importable'] = false;

?>

And repeated it for Leads and Prospects (adjusting the namespace of course).

  1. At the end I created the file “FP_events_subpanel_fp_events_contacts.php” in “custom/modules/Contacts/metadata/subpanels/” with the following code:
<?php
// created: 2025-01-23 13:17:42
$subpanel_layout['list_fields'] = array(
  'checkbox' =>
  array(
    'vname' =>  'LBL_Blank',
    'widget_type' => 'checkbox',
    'widget_class' => 'SubPanelCheck',
    'checkbox_value' => true,
    'width' => '5%',
    'sortable' => false,
    'default' => true,
  ),
  'name' =>
  array(
    'name' => 'name',
    'vname' => 'LBL_LIST_NAME',
    'sort_by' => 'last_name',
    'sort_order' => 'asc',
    'widget_class' => 'SubPanelDetailViewLink',
    'module' => 'Contacts',
    'width' => '20%',
    'default' => true,
  ),
  'account_name' =>
  array(
    'name' => 'account_name',
    'module' => 'Accounts',
    'target_record_key' => 'account_id',
    'target_module' => 'Accounts',
    'widget_class' => 'SubPanelDetailViewLink',
    'vname' => 'LBL_LIST_ACCOUNT_NAME',
    'width' => '20%',
    'sortable' => false,
    'default' => true,
  ),
  'phone_work' =>
  array(
    'name' => 'phone_work',
    'vname' => 'LBL_LIST_PHONE',
    'width' => '15%',
    'default' => true,
  ),
  'email1' =>
  array(
    'name' => 'email1',
    'vname' => 'LBL_LIST_EMAIL',
    'widget_class' => 'SubPanelEmailLink',
    'width' => '20%',
    'sortable' => false,
    'default' => true,
  ),
  'testrecord' =>
  array(
    'vname' => 'LBL_TESTRECORD',
    'widget_type' => 'checkbox',
    'width' => '5%',
    'sortable' => true,
    'default' => true,
  ),
  'event_status_name' =>
  array(
    'vname' => 'LBL_STATUS',
    'width' => '10%',
    'sortable' => false,
    'default' => true,
  ),
  'event_accept_status' =>
  array(
    'width' => '10%',
    'sortable' => false,
    'default' => true,
    'vname' => 'LBL_ACCEPT_STATUS',
  ),
   'edit_button' =>
  array(
    'vname' => 'LBL_EDIT_BUTTON',
    'widget_class' => 'SubPanelEditButton',
    'module' => 'Contacts',
    'width' => '5%',
    'default' => true,
  ),
  'remove_button' =>
  array(
    'vname' => 'LBL_REMOVE',
    'widget_class' => 'SubPanelRemoveButton',
    'module' => 'Contacts',
    'width' => '5%',
    'default' => true,
  ),
  'e_accept_status_fields' =>
  array(
    'usage' => 'query_only',
  ),
  'event_status_id' =>
  array(
    'usage' => 'query_only',
  ),
  'e_invite_status_fields' =>
  array(
    'usage' => 'query_only',
  ),
  'event_invite_id' =>
  array(
    'usage' => 'query_only',
  ),
  'first_name' =>
  array(
    'name' => 'first_name',
    'usage' => 'query_only',
  ),
  'last_name' =>
  array(
    'name' => 'last_name',
    'usage' => 'query_only',
  ),
  'salutation' =>
  array(
    'name' => 'salutation',
    'usage' => 'query_only',
  ),
  'account_id' =>
  array(
    'usage' => 'query_only',
  ),
);

Repeated it for Leads ans Prospects and then again a Quick Repair & Restore.

Conclusion:

  • I can see the relationship to the Events in the Contacts, Leads and Prospect in a subpanel.
  • I can see the testrecord checkbox in the subpanel of the Event
  • BUT it won’t be populated with data from the DB.

Since the subpanel in Events is not an ordinary subpanel, I am currently struggeling a lot. Any help would be appriciated very much.

Btw: I am using SuiteCRM 8.8.0 in DEV and PROD.

Cheers,
Carsten

If you don’t know this post, it has plenty of nice material, although mostly for v7:

Check out the links mentioning “Fields in relationships” which is what you’re trying to do, if I am not mistaken. It’s not just 3 steps, I am afraid…

Hi @pgr

It is not easy to implement it, but with the other documentations, it’s a doable. I couldn’t figure out, how it will works with a Boolen field → I never got it running. But if I use VCHAR field and refere it to a selection list, it works. Now, I have to rewrite all my changes, but the result counts at the end. :slight_smile:

Thank you for your hint.

Cheers,
Carsten

1 Like