After a deep dive into suitecrm I have now figured out how to implement this!
So I was mistaken in thinking that this is implemented within the popup def to the target module.
It is instead within the vardefs of the current record.
I believe the terminology for this feature is: initial filters
so in the field definition for the relate field in which you will need to set a displayParams array with a key value pair of initial_filter => ā&field_name=value&another_field_name=another_valueā
I believe the popup window shares functionality with the advanced filters from a list view and so any field name you want to set filters on needs ā_advancedā appended on the end
so the full example
lets say the name of the field I wish to filter on is called status and the value I wish to have set is Active I would put into my edit
$dictionary[$module_name]['fields']['relate_field_name']['displayParams'] = [
'initial_filter' => "&status_advanced=Active"
];
if the field is in the popup defs you will see the values already set in the filters and the initial list is filtered.
If you do not want the end user to be able to change the filter, you can remove the field from the popup and it will still work
Bonus knowledge :woohoo:
some modules stray from the norm like AOS_Quotes and AOS_Products_Quotes(line items)
The line item UI is not generated via smarty and instead is created by js and unfortunately the layout and the way the buttons behave is essentially hard coded and ignores custom displayParams within the vardefs
but all popups are opened by a call to the function āopen_popupā and the line items are no exception,
using line items as an example you can find the call to open_popup within <suitecrm_dir>/modules/AOS_Products_Quotes/line_items.js around line 281 within the openProductPopup function.
the fourth parameter is for initial_filters. when generated by smarty the calls to open_popup are bound to the parameters set in vardef but in this case you just change the empty string in this call with what you would have put into the var def
and so the call changes from
open_popup('AOS_Products', 800, 850, '', true, true, popupRequestData);
to
open_popup('AOS_Products', 800, 850, '&product_status_c_advanced=Active', true, true, popupRequestData);