Adding custom create button to list-headerpane

Hi all,

I'm working on an instance of SugarServe 10.2.

Following guidance from here and this article (https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.2/Cookbook/Adding_Buttons_to_the_Record_View/#Defining_the_Button_Label) I've been trying to create a custom button on the Accounts module list-headerpane, however after uploading and installing my custom module, and running a Quick Repair and Rebuild, my custom button is still not appearing. Can anyone see what the issue is here?

Here is the manifest file:

<?php

$manifest = array(
'key' => 1,
'name' => 'Accounts Types',
'description' => 'Example Description',
'author' => 'CompanyNet',
'version' => '10.2.0',
'is_uninstallable' => true,
'published_date' => '2020-10-14 15:24:00',
'type' => 'module',
'acceptable_sugar_versions' =>
array(
'exact_matches' => array(
'10.2.0'
),
//or
'regex_matches' => array(
'10.*' //any 10.0 release
),
),
'acceptable_sugar_flavors' =>
array(
'PRO',
'ENT',
'ULT'
),
'readme' => '',
'icon' => '',
'remove_tables' => '',
);

I've added the custom button like so:

custom\modules\Accounts\clients\base\views\list-headerpane\list-headerpane.php

<?php
/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* support.sugarcrm.com/.../.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/

$viewdefs['base']['view']['list-headerpane'] = array(
'fields' => array(
array(
'name' => 'title',
'type' => 'label',
'default_value' => 'LBL_MODULE_NAME',
),
array(
'name' => 'collection-count',
'type' => 'collection-count',
),
),
'buttons' => array(
array(
'name' => 'create_button',
'type' => 'button',
'label' => 'LBL_CREATE_BUTTON_LABEL',
'css_class' => 'btn-primary',
'acl_action' => 'create',
'route' => array(
'action'=>'create'
)
),
array(
'name' => 'create_SL_button',
'type' => 'button',
'label' => 'LBL_CREATE_SL_BUTTON_LABEL',
'css_class' => 'btn btn-primary',
),
array(
'name' => 'sidebar_toggle',
'type' => 'sidebartoggle',
),
),
);

I've extended the controller as follows:

custom\modules\Accounts\clients\base\views\list-headerpane\list-headerpane.js

/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* support.sugarcrm.com/.../.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
/**
* @class View.Views.Base.ListHeaderpaneView
* @alias SUGAR.App.view.views.BaseListHeaderpaneView
* @extends View.Views.Base.HeaderpaneView
*/
({
extendsFrom: 'HeaderpaneView',

/**
* @inheritdoc
*/
initialize: function(options) {
// FIXME: SC-3594 will address having child views extending metadata
// from its parent.
options.meta = _.extend(
{},
app.metadata.getView(null, 'list-headerpane'),
app.metadata.getView(options.module, 'list-headerpane'),
options.meta
);

this._super('initialize', [options]);

//shortcut keys
app.shortcuts.register({
id: 'List:Headerpane:Create',
keys: 'a',
component: this,
description: 'LBL_SHORTCUT_CREATE_RECORD',
handler: function() {
var $createButton = this.$('a[name=create_button]');
if ($createButton.is(':visible') && !$createButton.hasClass('disabled')) {
$createButton.get(0).click();
}
}
});

// Listener for custom button
this.context.on('button:create_SL_button:click', this.create_SL_button, this);
},

create_SL_button: function(evt) {
var accountType = this.model.get(this.def.cn_accounttype_c);

/**
* code goes here
*/

}
})

And I've defined the Button Label as follows:

custom\modules\Accounts\Ext\Language\en_UK.AccountsTypes.php

<?php
$mod_strings['LBL_CREATE_SL_BUTTON_LABEL'] = 'Create Social Landlord';
Parents
  • Hi ,

    I noticed your other question about installdefs and that is the missing piece here. You should have an installdefs section, in order to copy your files from your package into the application. Without it, none of the files will be copied. You should specify all of your customized files in your list in the $installdefs['copy'] section, eg:

    $installdefs['copy'] = array(
    array(
    'from' => '<basepath>/Files/custom/modules/Accounts/clients/base/views/list-headerpane/list-headerpane.php',
    'to' => 'custom/modules/Accounts/clients/base/views/list-headerpane/list-headerpane.php',
    ),
    );
Reply
  • Hi ,

    I noticed your other question about installdefs and that is the missing piece here. You should have an installdefs section, in order to copy your files from your package into the application. Without it, none of the files will be copied. You should specify all of your customized files in your list in the $installdefs['copy'] section, eg:

    $installdefs['copy'] = array(
    array(
    'from' => '<basepath>/Files/custom/modules/Accounts/clients/base/views/list-headerpane/list-headerpane.php',
    'to' => 'custom/modules/Accounts/clients/base/views/list-headerpane/list-headerpane.php',
    ),
    );
Children