Skip to content

Error getting Potentials related to a Contact

There is "strange relationship" between Contacts and Potetials. It's actually a dual relationship that is treated as a special case throughout the code.

Potentials has a field for the related Contact: vtiger_potential.contact_id

But also there is a dedicated relation table: vtiger_contpotentialrel

So, we have 2 ways to connect a Contact to Potentials:

  1. In the Edit form, selecting one Contact
  2. In the relation list view, selecting as many Contacts you want

How to reproduce the bug:

  1. Create a Potential (P) connecting a Contact (C1) in the Edit form. Save
  2. Add a second Contact (C2) in the related list
  3. Add a comment to P
  4. Open C1 and toggle Roll up on - you don't see P's comment
  5. Open C2 and toggle Roll up on - you see P's comment
  6. Bonus track: unlink C1 from P's related contacts list. Link it again. You will see P's comment in C1 Roll up.

The error is in the public function getRelatedModuleRecordIds in modules/Vtiger/models/Module.php

I'm providing a patch for it.

It's funny I checked VT 7.1.0 and the bug was reversed: you see comment at point 4. and not at 5 (looking ad diff between the two versions of file is clear why)