4

We have 2 modules in SugarCRM.

Module 1 = Built in Contacts module

Module 2 = Custom module called QMS module.

We would like to be able to create a new contact user record in the contacts module and then have a subpanel in that contacts module that would show all related qms module records that are related to the contact record based on them having the same matching email field.

So to clarify...In the contacts module there is a default email field.

In our custom qms module we also have another email field.

When you view a contact module record with the email field value of test@test.com then in a sub panel it should show any qms module records that also have a matching email field that have a value of test@test.com

This is not built in standard behavior in SugarCRM CE 6.xx. Does anyone know how we can achieve such functionality?

Daniel
  • 795
  • 1
  • 10
  • 25
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • so where is your code? – Alex Feb 27 '15 at 00:43
  • @Alex I have no code, this is a very complex process which I need help in knowing which files and what code to use in which files...I build many sugarcrm modules but I am stuck on this. All the articles related to it do not work. I am about to give up on this method and go a different route by using logic hooks and simply SQL query the DB to get related contact records to my custom module based on the matching email field. The hard part is that actual email value are not stored in the contacts table.... – JasonDavis Feb 27 '15 at 19:21
  • if you have no code, do you really beleive that here must be anybody who will code for you? – Alex Feb 27 '15 at 19:22
  • In other words there is no easy way to do this desired functionality but at least if I use the logic hook method then I can start coding and making progress – JasonDavis Feb 27 '15 at 19:24
  • 1
    @alex no but if there is a SugarCRM expert that see's this post with a bounty then perhaps they can tell me which vardef files to edit and help get me started...I am guessing you are not familiar with sugarcrm? What I am trying to achieve has been done before so there are people out there that know the process. I can appreciate your comments trying to school me in the way of StackExchange as if I am a rookie here but I am not....this is a legit question, no code is even needed to be a successful answer – JasonDavis Feb 27 '15 at 19:25
  • I did some modifications for the client with sugarCRM, but requirements was always much more detailed :-) – Alex Feb 27 '15 at 19:27
  • I have built many really advanced sugarcrm modules...this is not a simple fix where a snippet of code will do. This is actually much harder to do than one might think. Of all the advanced functionality and modules i've built for Sugar, this simple looking functionality is probably actually harder than most. It will take a Sugar expert to answer otherwise I would of had it resolved myself trust me – JasonDavis Feb 27 '15 at 19:30
  • I don't want to argue with you. I just tell you why I don't spend time on your case. Just because it is absolutely unclear. And it seems to me that you want somebody make job for you. So if you do some effort and put some code, screenshots, explanations I am sure here will be much more comments and answers than you have now. – Alex Feb 27 '15 at 19:33

1 Answers1

5

To accomplish this you need to create a custom function to fetch the data for your subpanel.

When implementing the QMS subpanel in modules/parent_module/metadata/subpaneldefs.php

'qms' => array(
        'order' => 40,
        'module' => 'QMS',
        'sort_order' => 'desc',
        'sort_by' => 'date_closed',
        'get_subpanel_data' => 'function:get_qms_contacts_subpanel',
        ...
        ),

Instead of providing a link field for get_subpanel_data, we tell it to use a function. This will tell the QMS subpanel to fetch the related records using the get_qms_contacts_subpanel function

Then in custom/Extension/application/Ext/Utils/some_file_name.php

Construct a function that will be used to form the query for your records.

<?php

function get_qms_contacts_subpanel()
{
   return array(
        "select" => "select distinct qms.id",
        "from" => "from qms",
        "join" => "join contacts on contacts.qms_id = qmd.contact_id" /*Obviously not the actual query but you get the point*/
        "where" => "where qms.email = contacts.email" /*See above*/
    );
}

I hope this helps.

See modules/Accounts/metadata/subpaneldefs.php for an example See the how the Emails subpanel fetches the Emails.

Check include/utils.php for the function used in the Email subpanel for more info on how to construct your function.

paquino
  • 464
  • 2
  • 5
  • This worked great. I ended up going into Studio and adding the Subpanel. After that, I then did the code changes mentioned in your answer to get my subpanel data using the custom Function method. I am not sure if I needed to add the subpanel from Studio first or not or if there was a better/code only method to add the subpanel and then use your method on but wanted to mentioned that I had to first add the subpanel. Thanks . If you have anymore info on this part would love to hear for future knowledge! – JasonDavis Mar 06 '15 at 07:06