AnsweredAssumed Answered

7.1.0 custom buttons and removing them depending on some logic

Question asked by community-support on Jan 13, 2014
Latest reply on Jun 20, 2014 by Mike Solomon

[U][B]Required functionality[/B][/U]

We have a field called 'Status' in a module, which needs to go through strict transition; let's say A->B->C. We've set that field to be readonly so that it can't be edited, only viewed. In order to change the field, a user has to click on a custom button. This custom button was only available on the 'Detail View'.

If current 'Status' is 'A' then there is one button which says 'Progress to B'. On clicking this button, the status is changed to 'B'.

If current 'Status' is 'B' then there are two buttons, one which says 'Return to A', the other which says 'Progress to C'. The status field is then changed accordingly.

[U][B]Older CRM

           array (

             'customCode' => '',



In the [B]views.detail.php[/B] we then removed the buttons which weren't applicable by calling:




Finally we had a custom controller which was included through a logic hook which changed the 'Status' field value.

[U][B]New CRM v7.1.0[/B][/U]

In the version 7.1.0, we've been able to add buttons by extending the [B]record.php[/B] in 'custom/modules/Accounts/clients/base/views/record/record.php':


2 =>


             'type' => 'rowaction',

             'event' => 'button:save_button_custom:click',

             'name' => 'save_button',

             'label' => 'LBL_CUSTOM_BUTTON1',

             'css_class' => 'btn btn-primary',

             'showOn' => 'view',

             'acl_action' => 'edit',



And adding the action to [B]record.js[/B]:



     extendsFrom: 'RecordView',

     zipJSON: {},

     initialize: function (options) {

         app.view.invokeParent(this, {type: 'view', name: 'record', method: 'initialize', args:[options]});

         //add listener for custom button

         this.context.on('button:save_button_custom:click', this.doSomething, this);


     doSomething: function() {





[U][B]Questions (Solution sort after)[/B][/U]

In order to get back to our original customised solution, I need to be able to re-create the following:

  - Add multiple buttons (which I have done above)

  - [B]Remove [/B]them programatically based on the 'status' field value (as per original solution). So if 'Status' is 'A' then just show one button ('Progress to B'). If any other status, then show two buttons 'Progress' / 'Return'

Where would I do this in the code?

Many thanks in advance for any assistance.


(from akezerashvili)