In Sugar, how to customize popup search to display records depending on the selection of another relate field in Many-to-Many relationship scenario?
Asked Answered
F

0

11

I have two modules, consider A & B. In between them, there is many-to-many relationship. Now, there is another module, consider C. There is One-to-Many between A & C and B & C. Now while on editview of C module, both relate fields of module A & module B are present.

Now, after selecting any record from module A, while selecting records from module B, I want to show only those records which are related to the selected record of module A.

Now, I have came across these links, where they provided solution in the scenario of having One-to-Many relationship between these modules.

How can I customize the popup search to display possibilities depending on the parent page?

SugarCRM: relate field passing default values to pop-up select form

Wherein "One-to-Many" scenario, we can achieve the same by adding following code to editviewdefs.php file of targeted module, like this:

'displayParams' => array(
    'initial_filter' => '&contact_name_advanced="+encodeURIComponent(document.getElementById("contact_name").value)+"',
),

OR like this:

'displayParams' => array (   
    'initial_filter' => '&account_name={$fields.account_name.value}', 
),

But neither these posts mentioned any solution for "Many-to-Many" scenario nor I found any such post.

I came across another post:

SugarCRM Custom Query in popup list

where it suggested, along with above solution, to add few lines of code in popdefs.php file. But it is not wise option, as this popdefs.php file automatically generates by SugarCRM.

I came across few more posts:

How to Override view.popup in sugar CE 6.5.18

How I can customize query in view.popup in SugarCRM

where it suggested to customize the sql queries inside the popupview (view.popup.php) in SugarCRM. I tried that, but still I found no success. Kindly help. Thanks.

Flor answered 13/10, 2016 at 16:49 Comment(4)
I face this problem and i solved it , but it is very difficult to share , try to use custom filter and break down the many-to-many relation into one to many relation .Warhorse
Thank you @AmiteshKumar. I don't think I can break down that. It's been 5 days, that I am struggling to achieve this. I don't know, what do you mean "very dificult to share". But if possible, kindly help or give me some hint atleast.Flor
tell me i am correct or not , in c module you want if A select according to A , B data will filter if B select According to B A data will get filter , did i understand it ?Warhorse
Yeah , @AmiteshKumar you are correct.Flor

© 2022 - 2024 — McMap. All rights reserved.