AnsweredAssumed Answered

Sugar 7 : account module : add a custom button to create a related record from custom module

Question asked by Gaelle Fernandez on Jul 22, 2014
Latest reply on Jul 31, 2014 by Gaelle Fernandez
Hello everybody,

What i want :
I would like to add a custom button on Accounts module. This custom button would call the creation of a Contact+ record. Contact+ is a custom module i've created through ModuleBuilder and then customized through Studio. Accounts and Contacts+ have a M:M relationship, so on Accounts i can create a Contacts + through the subpanel.

But i also want to add a "Create Contacts+" button on Acounts record view. When clicking it, the drawer of Contacts+ create view has to appear and link this new Contact+ to the account.

What i already did :
I've already add my custom button, whithin these files :
custom/modules/Accounts/clients/base/views/record/record.php override the record.php by adding the following buttons array :

'buttons' => array(   array(
    'type' => 'button',
    'name' => 'cancel_button',
    'label' => 'LBL_CANCEL_BUTTON_LABEL',
    'css_class' => 'btn-invisible btn-link',
    'showOn' => 'edit',
   ),
   array(
    'type' => 'rowaction',
    'event' => 'button:save_button:click',
    'name' => 'save_button',
    'label' => 'LBL_SAVE_BUTTON_LABEL',
    'css_class' => 'btn btn-primary',
    'showOn' => 'edit',
    'acl_action' => 'edit',
   ),
   array(
    'type' => 'actiondropdown',
    'name' => 'main_dropdown',
    'primary' => true,
    'showOn' => 'view',
    'buttons' => array(
     array(
      'type' => 'rowaction',
      'event' => 'button:edit_button:click',
      'name' => 'edit_button',
      'label' => 'LBL_EDIT_BUTTON_LABEL',
      'acl_action' => 'edit',
     ),
     array(
      'type' => 'rowaction',
      'event' => 'button:create_cplus_button:click',
      'name' => 'create_cplus_button',
      'label' => 'LBL_CREATE_CPLUS_BUTTON',
      'acl_action' => 'edit',
     ),
     array(
      'type' => 'divider',
     ),
     array(
      'type' => 'shareaction',
      'name' => 'share',
      'label' => 'LBL_RECORD_SHARE_BUTTON',
      'acl_action' => 'view',
     ),
     array(
      'type' => 'pdfaction',
      'name' => 'download-pdf',
      'label' => 'LBL_PDF_VIEW',
      'action' => 'download',
      'acl_action' => 'view',
     ),
     array(
      'type' => 'pdfaction',
      'name' => 'email-pdf',
      'label' => 'LBL_PDF_EMAIL',
      'action' => 'email',
      'acl_action' => 'view',
     ),
     array(
      'type' => 'divider',
     ),
     array(
      'type' => 'rowaction',
      'event' => 'button:find_duplicates_button:click',
      'name' => 'find_duplicates_button',
      'label' => 'LBL_DUP_MERGE',
      'acl_action' => 'edit',
     ),
     array(
      'type' => 'rowaction',
      'event' => 'button:duplicate_button:click',
      'name' => 'duplicate_button',
      'label' => 'LBL_DUPLICATE_BUTTON_LABEL',
      'acl_module' => 'Accounts',
      'acl_action' => 'create',
     ),
     array(
      'type' => 'rowaction',
      'event' => 'button:audit_button:click',
      'name' => 'audit_button',
      'label' => 'LNK_VIEW_CHANGE_LOG',
      'acl_action' => 'view',
     ),
     array(
      'type' => 'divider',
     ),
     array(
      'type' => 'rowaction',
      'event' => 'button:delete_button:click',
      'name' => 'delete_button',
      'label' => 'LBL_DELETE_BUTTON_LABEL',
      'acl_action' => 'delete',
     ),
    ),
   ),
   array(
    'name' => 'sidebar_toggle',
    'type' => 'sidebartoggle',
   ),
  ),

Added custom/Extension/modules/Accounts/Ext/Language/en_us.customCreateCPlus.php and
custom/Extension/modules/Accounts/Ext/Language/fr_FR.customCreateCPlus.php, both containing this :

<?php $mod_strings['LBL_CREATE_CPLUS_BUTTON'] = 'Créer Contacts+';
?>

My question :

following this official article : http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_7.2/20_UI_Mode... I now have to extend and override Accounts record.js.

I don't know how to do this : how to trigger Contacts+ creation when clicking on "create Contacts+" button. I understand i have to add a listener to the button, but how do i launch and save the Contacts+ creation?

Maybe you could explain to me and get me on the right tracks.


Thank you sugar fellows.


Outcomes