Add a custom action to the buttons on the right of a subpanel Row

Hello,
based on the following topic(many thank, really helpful):

https://suitecrm.com/forum/developer-help/8486-how-to-add-a-custom-top-button-to-any-subpanel

What about to add action to right buttons in subpanels(see addaction.png)?

In particular i need to add action which open a popupview to a relate field and it displays the updated record whithin subpanel.

Any help is really appreciate…

Thank you

It can be done :wink:

If you look at the layout defs of your subpanel you will see the definitions for the edit and remove buttons. I am looking at custom/modules/Contacts/metadata/subpanels/Account_subpanel_contacts.php

In there I can see :


 '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,
  ),

notice that they both point to a widget_class

 'widget_class' => 'SubPanelEditButton'] 

And

'widget_class' => 'SubPanelRemoveButton', 

Widget classes are contained in : include/generic/SugarWidgets. But what you want to do is create your own widget class in custom/include/generic/SugarWidgets

If you inspect the actual edit button you will see a link similar to the following :

index.php?module=Contacts&action=EditView&record=6aa797c0-3b56-05b2-b2db-57ac8d113a4c&parent_module=Accounts&parent_id=cef2707e-3fd0-11e5-39d7-57557b10ceaf&return_module=Accounts&return_id=cef2707e-3fd0-11e5-39d7-57557b10ceaf&return_action=DetailView&return_relationship=contacts

What you need to do is create your definition in the subpanel layout defs that points to your own custom widget class that adds a link to your custom action in a similar manner to the above link.

Simple!!

1 Like

Thank you
i was almost in teh right direction…however something was not going as expected…

I will look better and i’ll let you know…

Thanks again

mmm…i’ve tried with no luck…
till now i was able to change only the button name…

What i need to do is to create a custom button called “Hook shipment” that can open a popup view and relate the field to my shipment module…once dne it should refresh and update me the field value visible in the subpanel list view…

Can you point me in the riegh direction?

Thank you