Today i stumbled upon a tricky need for us and have found no clue by searching the web and forum so far.
The Case:
We have the standardized Contacts Module and Projects Module.
We have Subpanel (many to many) Relationships between these two modules.
We have the Mail Merge Professional Module to get Documents with related data from within the Contacts Modules ListView.
What we need:
A possibility to filter the ListView of the Contact Module based on the Relatonship to the Project, though the ListView will just show the contacts related to the filtered project.
Which method doesn’t fit our need:
A related field inside the contact record relating to project is no fit, as we have many contacts which are part of many projects.
Amount of Data:
Around 500 to 1000 Contacts per Request
Hardware:
Performance should be no issue
Windows Server 2016
Exerience Level:
I work nearly two years for now with suitecrm on a daily basis and already have read a lot of literature on developing (including Suite CRM for Developers and the whole DEV Documentation) and customized various Modules (with/without Studio).
I would be very thankfull if somebody could give me a clue or solution for our need.
Hi, @taylordave85
You can take as example the array ‘email’ in file modules/Contacts/metadata/SearchFields.php
If you write correct SQL request I think that it will work.
Afterwards you can go into studio and add the field in your Quick Filter and/or Advanced Filter.
The field in the filter is a relate field, from which you can search and select existing Accounts. In case you need a text field (so you can use wildcards), then, after you have added the field to your filter, edit:
“id_name” refers to the id field in the relationship table. The relationship definitions are defined in the files in the directory metadata/ or custom/metadata/. The specific file can be found by checking that it begins with the found relationship “projects_contacts” in vardef.php in the previous step.
$dictionary['projects_contacts'] = array(
In this case, the metadata for the relationship is in metadata/projects_contactsMetaData.php
The id_name is defined as “join_key_lhs” or “join_key_rhs”:
“table” refers to the database table of the module, which can also be found in the vardefs.php file, see above
“rname” is the related database field to which is referred, in this case it refers to the field “name” in the database table “project”. It can be looked up in Studio by opening the fields and looking into the “Name” column
“vname” refers to the displayed name for the search field and can be self chosen, usually is in caps and starts with “LBL_”
THX @jansiero,
This was a great solution and it is very simple, fully meets our needs and is already implemented.
If another user questions if this solution will work with many-to-many relationships: YES IT WILL
@p.konetskiy, thank you for your hint, too. I will go with the vardef solution, but i will look into the bean solution, too. I will tell the result afterwards;)
@jansiero thanks for the instructions. I tried doing the same thing for Targets.
I am trying to add the ability to filter targets based on the related target list. however, no field is showing up.
Would you be able to look into this and see what I am doing wrong?