relate field filtered by passing value

Hi, there,
Iā€™m looking for a way to filter the popou result after clicking on a ā€˜relate fieldā€™.
I have Accounts module connected with a many to many relationship to my custom module.
I added a ā€˜relateā€™ field in the AOS_Quotes module pointing to my custom module.
Now what I would like to do is filter the values in the relate field according to the Account module assigned in the AOS_Quotes module.
Is it possible?
I followed the following article https://academe.co.uk/2013/03/sugarcrm-relate-field-passing-default-values-to-pop-up-select-form/ but I only get to pass a value to the parameter ā€˜initial_filterā€™ā€¦ then I would like to be able to process the value passed to present in the popup the filtered list of values based on the latter.

I report the piece of code I wrote in /custom/modules/AOS_Quotes/metadata/editviewdefs.php

array (
            'name' => 'per_azienda_c',
            'studio' => 'visible',
            'label' => 'LBL_PER_AZIENDA',
            'displayParams'=>array(
              'initial_filter'=>'&my_field_advanced={$fields.billing_account.value|urlencode}'
            )
          )

Thanks

You need to modigy the SQS. Check here for a sample:
https://community.sugarcrm.com/thread/20732

There is another method as discussed here:
https://suitecrm.com/suitecrm/forum/developer-help/19610-modify-quick-search-dropdown-for-products#68583

Thanks,

AlxGr

Thanks AlxGr,
Iā€™m new to SuiteCrm, what is an SQS object?

SQS = Sugar Quick Search = Quick Search.

Quick Search is the part of the system that displays suggestions when you start typing on a relate field or from the search view of any module.

Thanks AlxGr,
following various articles I was able to understand how to filter the data in the popup of a relate field based on a field of the linked module.
Unfortunately, I have a slightly more complicated problem, in the sense that I should filter the data according to a report.
In my case the relate field on the Opportunity module is related to the Account module, but it will have to filter the data according to a parameter, always set in the Reference Opportunity, which should be used in a where condition for the filter.
Account is related to a custom Module and this parameter should filter me all the Companies connected to the custom module that ahnno that parameter.
I read the article https://community.sugarcrm.com/thread/20732, how do I pass the parameter to the function functionQS(),and use it as a filter condition? It would also be useful to understand how to use the parameters of the sqs_objects e.g. ā€œconditionsā€, ā€œmethodsā€ā€¦

Let me describe my problem better:
In the editing form of the Opportunities module I have two related fields that point respectively to the Accounts modules and to my custom ā€˜Company ESPā€™ module.
The Company and ā€˜ESP Companyā€™ modules are related to many to many.
What I would like to do in the Edting view of the Opportunity module is that when I select a value from the relate field ā€˜Company ESPā€™ I filter the values of the relate field ā€˜Companyā€™ according to those chosen in the previous field.

Instead of a relate field for the company module I also thought to use a non-db field as explained in the article http://www.urdhva-tech.com/blogs/filter-by-related-module-s-field.
The problem is that I wouldnā€™t know how to pass the value of the chosen ā€˜Company ESPā€™ field to this last non-db filed.

Any advice?

So that is a complicated combination. I believe it involved SQS and inline editing.

Check this post for ideas on how to work with inline editing:

Thanks,

AlxGr

1 Like