Subpanel right button action to Listview

Hi all,
never done it before which requires me to ask to point me in a right direction.

I need to create a new button on the right of every subpanel records(just like Edit or Remove) which redirects the user to the list view of a related child module filtered by record itself.

Contract Module related to Purchase Order(O2M) which is related with Items(O2M).
When user are in Contracts(Detail View) it should be able to click on "get filtered result button " in Purchase Orders record present in subpanel abd it will redirected to Items listview and see all items filtered by selected Purchase Order.

Hope it is clear and someone can point me on teh right direction.

Many Thanks

There are all buttons here: include/generic/SugarWidgets:

  1. SugarWidgetSubPanelCloseButton.php
  2. SugarWidgetSubPanelEditButton.php
  3. SugarWidgetSubPanelRemoveButton.php

You cab create your button into custom directory: custom/include/generic/SugarWidgets

What is relationship between both modules , one to many or many to many?

One to Many

Contracts is related One2Many to Purchase Orders
Purchase Orders is related One2Many to Items

Just for better user’s view also Contracts is related to Items too

Thanks for your hint

I’ve done the custom SubpanelWidget as you suggest and it is working great, this button will redirect to a custom filtered List View.

My needs was also to remove Edit and Remove buttons keeping only the custom one.
What i see is that when Suite has only one button on the right it becomes bigger than expected and it renders very bad.

Please see attached screenshots.
With Custom and Remove Button it look nice:

with 2 buttons

With only Custom Button it renders too big:

with 1 button

You can use custom css file each themes: custom/themes/SuiteP/css/Dawn/style.css

Hello, can you please help me. my new button appears only when i’m using default SugarWidget (ex Remove, Edit). By the way crm finds my new sugarwidget. but I don’t know how to set my own label to do new logic for button.