Initial Filter Opportunity field by selected Account in Contracts module — SuiteCRM 8.8

I’d like to implement an initial filter
In the Contracts module, I have two relate fields:

  • Account
  • Opportunity

I want this behavior:
:white_check_mark: When I select an Account, and then click to choose an Opportunity, the Opportunity dropdown or popup should only show Opportunities related to the selected Account — not all Opportunities.

Could anyone please guide me on?

Hey
Since the Contracts module is running Legacy views you can use something like

   1 =>
        array(
          0 =>
          array(
            'name' => 'billing_contact',
            'label' => 'LBL_BILLING_CONTACT',
            'displayParams' =>
            array(
              'initial_filter' => '&account_name="+this.form.{$fields.billing_account.name}.value+"',
            ),
          ),
          1 => '',
        ),

For reference
This is the file that contains the code
public/legacy/modules/AOS_Invoices/metadata/editviewdefs.php

1 Like

Thank you for your response.
However, we require this feature to be available within the Angular modules.

Today, I identified a solution to set a static value using the initial filter. However, I would like to understand how we can achieve the same functionality using dynamic values.

Yes, this is one of those “hybrid pain points” in SuiteCRM 8. Angular modules don’t work with true dynamic initial_filter like old views do.

You can cheat with this.form.xxx.value in legacy (editviewdefs.php) because the JS context is there when the page is rendered. In Angular (ng-client), that context is gone. The filter config is checked before the relate popup knows about the values of other fields.

What is working right now:

You can only pass static filters in metadata/detailviewdefs.php or recordviewdefs.php.

Dynamic values, such as “selected Account → filter Opportunities,” need more than just metadata; they need custom frontend logic.

People are using these realistic options:

Custom Angular logic (a clean way)
When the popup opens, override the relate field component and add a filter.
You basically connect to the RelateFieldComponent, listen for account changes, and change the filters that are sent to the backend.

A semi-hack for the backend
Add a custom API or logic hook that reads the parent record (Account) and filters Opportunities on the server. It works, but it’s not pretty.

For now, accept the legacy view.
A lot of people still use this interaction in legacy because Angular isn’t ready for dependent relate filters yet.

TL;DR: :check_mark: static filter = supported :cross_mark: SuiteCRM 8 Angular doesn’t support dynamic filters from other fields right away. You need to make a custom Angular override or add backend logic to make it work.

You’re already on the right track if you’re working with SuiteCRM-Core. Just don’t expect metadata to fix everything.