问题
I need to customize the list of element shows in a popupview based on a relation.
I have these modules:
A->x (one-to-many)
A->y (one-to-many)
x have a related field to y
In detailview of A, a have the subpanels for x and y modules and I can create new x records and y records from quickcreateview.
In quickcreateview for y, I have to select by popupview an x element.
I have to customize this popupview for showing only x items that have relation with current (this detailview) A record (not all)
This solution is valid for me: How I can customize query in view.popup in SugarCRM
but I need to create a query with a dynamic param with A.id
回答1:
Solved. In quickcreatedefs(in my example module 'y'), in related field to 'x' add:
'displayParams' => array(
'initial_filter' => "&linea_id=".$_REQUEST['parent_id'],
),
$_REQUEST['parent_id'] is id of 'A' module.
And in popupdefa(in my example module 'x'), add:
'whereStatement'=> " id IN (SELECT presu_line9cc5aterial_idb from presu_lineastesmaterial_c where presu_line9fedupuesto_ida='".$_REQUEST['linea_id']."' and deleted=0)",
来源:https://stackoverflow.com/questions/29687238/sugarcrm-custom-query-in-popup-list