how to create extra button on list view

Using sugar 10 I am trying to add extra button on list view which will update 2 column on that record. change assign to and status.

I have followed these articles but they don't seem to work

https://medium.com/shanes-tech-tips/sugarcrm-7-adding-an-action-to-the-listview-436f18c039e6

https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/442/how-to-add-option-in-action-menu-of-module-listview---7-x

https://medium.com/shanes-tech-tips/sugarcrm-7-adding-an-action-to-the-listview-headerpanel-cdfff560e7b3

https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1175/updating-a-record-from-a-list-view-using-the-action-dropdown

I have managed to get the button to display in massupdate section

 

<?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.
*/
$module_name = 'ModuleName';
$viewdefs[$module_name]['base']['view']['recordlist'] = array(
'favorite' => true,
'following' => true,
'sticky_resizable_columns' => true,
'selection' => array(
'type' => 'multi',
'actions' => array(
array(
'name' => 'export_button',
'type' => 'button',
'label' => 'LBL_EXPORT',
'acl_action' => 'export',
'primary' => true,
'events' => array(
'click' => 'list:massexport:fire',
),
),
array(
'name' => 'book_button',
'type' => 'button',
'label' => 'LBL_BOOK',
'acl_action' => 'book',
'primary' => true,
'events' => array(
'click' => 'list:massbook:fire',
),
),
),
),
'rowactions' => array(
'actions' => array(
array(
'type' => 'rowaction',
'css_class' => 'btn',
'tooltip' => 'LBL_PREVIEW',
'event' => 'list:preview:fire',
'icon' => 'fa-eye',
'acl_action' => 'view',
),
array(
'type' => 'rowaction',
'name' => 'edit_button',
'label' => 'LBL_EDIT_BUTTON',
'event' => 'list:editrow:fire',
'acl_action' => 'edit',
),
array(
'type' => 'follow',
'name' => 'follow_button',
'event' => 'list:follow:fire',
'acl_action' => 'view',
)
),
),
'last_state' => array(
'id' => 'record-list',
),
);

and recordlist.js

({
extendsFrom:'RecordlistView',
initialize:function(options){
this._super('initialize',[options]);
this.context.on('list:massbook:fire',this.massbookFunc,this);
},
massbookFunc:function(){
console.log("Test button in list view gets called");
var massCollection = this.context.get("mass_collection");
var id_array = [];
massCollection.each(function(data){
id_array.push(data.id); //pushing ids of selected
});
}
})


I am not sure how to proceed with updating the 2 columns in the record

 

Parents
  • Hi Sharif,

    If you want to add a new button in the List view, you can extend the list-headerpane.php file from the core path -  clients/base/views/

    list-headerpane/list-headerpane.php to custom path

    and create a file in the respective path -  custom/modules/<moduleName>/clients/base/views/list-headerpane/list-headerpane.php

    In this file, you can add your button.

    But can you please tell me clearly when do you want to update the assigned to and status field in the record. Is there any specific action that should update these fields. Based upon your requirement, we can check what needs to be done. 

    Thank you,

    Poojitha.K

  • When they click the drop down button "book" i want it to update the status and assigned column of that record

    I have now got

    massbookFunc:function(){
    var id_array = [];
    var massCollection = this.context.get('mass_collection');
    massCollection.each(function(data){
    id_array.push(data.id); //pushing ids of selected
    });
    console.log(id_array)

    app.api.call(
    'PATCH',
    app.api.buildURL("Module", null, null, {}),
    {id: id_array},
    {
    success: function (data) {
    app.alert.show('booking-ok', {
    level: 'success',
    messages: 'Module successfully booked',
    autoClose: true
    });
    },
    error: function (e) {
    app.alert.show('failure', {
    level: 'error',
    title: 'There was an error booking Module',
    autoClose: false
    });
    }
    },
    { async:true },
    );
    }


    But this does a GET request. My api I have



    'updateWorkOrder' => [
    'reqType' => ['PATCH'],
    'path' => ['Module'],
    'pathVars' => [''],
    'method' => 'updateModule',
    'minVersion' => '10',
    'shortHelp' => 'The end point for updating existing Module',
    //'longHelp' => 'custom/clients/base/api/help/Cases_createModule_help.html',
    'noLoginRequired' => false,
    ],
Reply
  • When they click the drop down button "book" i want it to update the status and assigned column of that record

    I have now got

    massbookFunc:function(){
    var id_array = [];
    var massCollection = this.context.get('mass_collection');
    massCollection.each(function(data){
    id_array.push(data.id); //pushing ids of selected
    });
    console.log(id_array)

    app.api.call(
    'PATCH',
    app.api.buildURL("Module", null, null, {}),
    {id: id_array},
    {
    success: function (data) {
    app.alert.show('booking-ok', {
    level: 'success',
    messages: 'Module successfully booked',
    autoClose: true
    });
    },
    error: function (e) {
    app.alert.show('failure', {
    level: 'error',
    title: 'There was an error booking Module',
    autoClose: false
    });
    }
    },
    { async:true },
    );
    }


    But this does a GET request. My api I have



    'updateWorkOrder' => [
    'reqType' => ['PATCH'],
    'path' => ['Module'],
    'pathVars' => [''],
    'method' => 'updateModule',
    'minVersion' => '10',
    'shortHelp' => 'The end point for updating existing Module',
    //'longHelp' => 'custom/clients/base/api/help/Cases_createModule_help.html',
    'noLoginRequired' => false,
    ],
Children
No Data