Unrelated Emails showing in oppertunity history subpanel

My opportunities are showing unrelated contacts, archived emails and so fourth in the history subpanel. This only occurs for opportunities. This problem started only after upgrading a few installations ago, I cant remember the version when this first started. I have the default relationships for opportunity history. Why are unrelated emails being shown in the history subpanel and is there a way to fix this? Thanks!

Try a few repairs from Admin / Repairs

  • Quick repair and rebuild

  • repair relationships

Thank you for the suggestions. I tried both but the unrelated emails/corresponding contacts are still showing up in the history subpanel.

This is very strange and I never heard of such a bug… :thinking:

Are you technical enough to go in the database and check how the data looks like there?

I would start by setting log level to DEBUG in Admin / System Settings. This will cause all your queries to be logged in suitecrm.log. From there, you can get the query that is driving that subpanel and go in the database to see why it’s getting some inadequate data.

Thanks pgr! That’s a really great idea. I’ll try this during off hours and let you know the results. Excellent suggestion!

I ran the following but didn’t see anything where it was populating the oppertunities_contacts table from my database or interacting with the subpanel. Perhaps I missed something? Heres what I got when i did a
cat /var/www/html/SuiteCRM/suitecrm.log Sorry for posting so much.

Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0060698986053467
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0023059844970703
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0022428035736084
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0020520687103271
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0019869804382324
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::after_save
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOD_LogicHooks without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: AOD_Index::before_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Retrieve AOD_Index : SELECT aod_index.* FROM aod_index  WHERE aod_index.id = '1' AND aod_index.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT aod_index.* FROM aod_index  WHERE aod_index.id = '1' AND aod_index.deleted=0 Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT aod_index.* FROM aod_index  WHERE aod_index.id = '1' AND aod_index.deleted=0 LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0016548633575439
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean[AOD_Index].load_relationships, Loading relationship (assigned_user_id).
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean.load_relationships, failed Loading relationship (assigned_user_id)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean[AOD_Index].load_relationships, Loading relationship (assigned_user_id).
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean.load_relationships, failed Loading relationship (assigned_user_id)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: AOD_Index::after_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AssignGroups without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOW_WorkFlow without parameters
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = 'SchedulersJobs' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0017659664154053
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * hours
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * mins
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 13:30:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler found valid job (Run Report Generation Scheduled Tasks) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Get One: |SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active'|
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0018081665039062
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::before_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Retrieve User : SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0018858909606934
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT u1.first_name, u1.last_name from users  u1, users  u2 where u1.id = u2.reports_to_id AND u2.id = '1' and u1.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0015170574188232
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean[User].load_relationships, Loading relationship (reports_to_link).
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT
                    ea.email_address,
                    ea.email_address_caps,
                    ea.invalid_email,
                    ea.opt_out,
                    ea.confirm_opt_in,
                    ea.date_created,
                    ea.date_modified,
                    ear.id,
                    ear.email_address_id,
                    ear.bean_id,
                    ear.bean_module,
                    ear.primary_address,
                    ear.reply_to_address,
                    ear.deleted
                FROM email_addresses ea LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
                WHERE
                    ear.bean_module = 'Users'
                    AND ear.bean_id = '1'
                    AND ear.deleted = 0
                ORDER BY ear.reply_to_address, ear.primary_address DESC
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0017549991607666
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::after_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::before_save
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:INSERT INTO job_queue (assigned_user_id,id,name,deleted,date_entered,date_modified,scheduler_id,execute_time,status,resolution,target,requeue,job_delay,client)
					VALUES ('1','a0cd1b87-a2de-25a7-6786-5eab52ad83b0','Run Report Generation Scheduled Tasks',0,'2020-04-30 22:36:01','2020-04-30 22:36:01','1dc5c866-3aa7-34cf-00ca-579bc167d4d1','2020-04-30 22:36:01','queued','queued','function::aorRunScheduledReports',0,0,'')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0054450035095215
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0022788047790527
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.002251148223877
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0020668506622314
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0021359920501709
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::after_save
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOD_LogicHooks without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AssignGroups without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOW_WorkFlow without parameters
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = 'SchedulersJobs' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0015039443969727
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Prune Tracker Tables) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * hours
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * mins
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 19:00:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler found valid job (Check Inbound Mailboxes) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Get One: |SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active'|
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0017027854919434
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::before_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Retrieve User : SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0019450187683105
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT u1.first_name, u1.last_name from users  u1, users  u2 where u1.id = u2.reports_to_id AND u2.id = '1' and u1.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0014829635620117
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean[User].load_relationships, Loading relationship (reports_to_link).
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT
                    ea.email_address,
                    ea.email_address_caps,
                    ea.invalid_email,
                    ea.opt_out,
                    ea.confirm_opt_in,
                    ea.date_created,
                    ea.date_modified,
                    ear.id,
                    ear.email_address_id,
                    ear.bean_id,
                    ear.bean_module,
                    ear.primary_address,
                    ear.reply_to_address,
                    ear.deleted
                FROM email_addresses ea LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
                WHERE
                    ear.bean_module = 'Users'
                    AND ear.bean_id = '1'
                    AND ear.deleted = 0
                ORDER BY ear.reply_to_address, ear.primary_address DESC
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0025479793548584
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::after_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::before_save
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:INSERT INTO job_queue (assigned_user_id,id,name,deleted,date_entered,date_modified,scheduler_id,execute_time,status,resolution,target,requeue,job_delay,client)
					VALUES ('1','abca0e6f-afaf-fb84-c706-5eab523cde6a','Check Inbound Mailboxes',0,'2020-04-30 22:36:01','2020-04-30 22:36:01','213587a9-5d69-1196-acc4-579bc1eda524','2020-04-30 22:36:01','queued','queued','function::pollMonitoredInboxesAOP',0,0,'')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0052430629730225
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0023050308227539
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0020308494567871
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.001990795135498
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0019781589508057
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::after_save
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOD_LogicHooks without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AssignGroups without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOW_WorkFlow without parameters
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = 'SchedulersJobs' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0014069080352783
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 18:30:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Run Nightly Process Bounced Campaign Emails) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 18:30:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Run Nightly Mass Email Campaigns) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 16:15:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Perform Lucene Index) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 13:15:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Optimise AOD Index) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * hours
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * mins
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 19:00:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler found valid job (Run Email Reminder Notifications) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Get One: |SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active'|
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM users WHERE id = '1' AND is_admin = 1 AND deleted = 0 AND status = 'Active' LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0017220973968506
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::before_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Retrieve User : SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0018699169158936
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT u1.first_name, u1.last_name from users  u1, users  u2 where u1.id = u2.reports_to_id AND u2.id = '1' and u1.deleted=0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0014858245849609
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SugarBean[User].load_relationships, Loading relationship (reports_to_link).
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT
                    ea.email_address,
                    ea.email_address_caps,
                    ea.invalid_email,
                    ea.opt_out,
                    ea.confirm_opt_in,
                    ea.date_created,
                    ea.date_modified,
                    ear.id,
                    ear.email_address_id,
                    ear.bean_id,
                    ear.bean_module,
                    ear.primary_address,
                    ear.reply_to_address,
                    ear.deleted
                FROM email_addresses ea LEFT JOIN email_addr_bean_rel ear ON ea.id = ear.email_address_id
                WHERE
                    ear.bean_module = 'Users'
                    AND ear.bean_id = '1'
                    AND ear.deleted = 0
                ORDER BY ear.reply_to_address, ear.primary_address DESC
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0018210411071777
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: Users::after_retrieve
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::before_save
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:INSERT INTO job_queue (assigned_user_id,id,name,deleted,date_entered,date_modified,scheduler_id,execute_time,status,resolution,target,requeue,job_delay,client)
					VALUES ('1','b592d5f8-645a-132c-0898-5eab529c4faa','Run Email Reminder Notifications',0,'2020-04-30 22:36:01','2020-04-30 22:36:01','2ade4f8e-faee-4629-549b-579bc184253f','2020-04-30 22:36:01','queued','queued','function::sendEmailReminders',0,0,'')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0056610107421875
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0022311210632324
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0020148754119873
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.002129077911377
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] SecuritySuite: Get SecuritySuite Enabled Modules: SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT lhs_module, rhs_module FROM relationships WHERE deleted=0 AND (lhs_module = 'SecurityGroups' OR rhs_module='SecurityGroups')
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0020508766174316
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Hook called: SchedulersJobs::after_save
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOD_LogicHooks without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AssignGroups without parameters
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Creating new instance of hook class AOW_WorkFlow without parameters
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = 'SchedulersJobs' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query Execution Time:0.0014231204986572
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2015-01-01 16:45:01 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Clean Jobs Queue) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Removal of documents from filesystem) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Prune SuiteCRM Feed Tables) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Schedulers->deriveDBDateTimes() got an object of type: Scheduler
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * day
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * months
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->got * dates
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Constraints: start: 2018-01-01 21:30:00 from: 1970-01-01 00:00:00 end: 2020-05-01 22:36:02 to: 2020-05-01 22:36:02 now: 2020-04-30 22:36:01
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] ----->Scheduler did NOT find valid job (Geocode Addresses) for time GMT(2020-04-30 22:36:00)
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Get One: |SELECT id FROM job_queue WHERE execute_time <= '2020-04-30 22:36:01' AND status = 'queued' ORDER BY date_entered ASC|
Thu Apr 30 18:36:01 2020 [11230][1][DEBUG] Limit Query:SELECT id FROM job_queue WHERE execute_time <= '2020-04-30 22:36:01' AND status = 'queued' ORDER BY date_entered ASC Start: 0 count: 1
Thu Apr 30 18:36:01 2020 [11230][1][INFO] Query:SELECT id FROM job_queue WHERE execute_time <= '2020-04-30 22:36:01' AND status = 'queued' ORDER BY date_entered ASC LIMIT 0,1

@pgr Would mail merge have anything to do with this?

What do you mean by “mail merge”?

In admin -> Users -> User Administration -> Create New User -> Advanced -> There is an option to check off mail merge. Its description wasn’t very helpful though. We dont have this checked off for any users. The database idea was great, but I don’t see whats causing random contacts to jump into the opportunity history SubPanel after looking at it in debug mode. I knew there must be some relationship, such as that the sender of the email is a contact on the opportunity; however, the email is for a different opportunity. It is as though history items (emails) are being auto-related based on the contact for some reason?

Mail merge seems to be a defunct SugarCRM feature, it is not used in SuiteCRM, as far as I can see. That user profile option should probably just be removed.

If you can find the full Query that is being used for the Opportunities subpanel, then that should be a very specific clue into your problem. It might also help to open phpMyAdmin and go examining the database tables (contacts, emails, opportunities) and the relationship tables connecting them.

Thanks PGR. I went into our database and I don’t see where the Opportunities subpanel within any of these tables or columns. I do have the following query to show everything from one of the many opportunities that has the issue. SELECT * FROM opportunities WHERE name = ‘Opportunity name’; However, it doesn’t even display any of the subpanel information. When I query all the information from the opportunities table thats all that shows. I searched the following tables:
opportunities ,
opportunities_audit
opportunities_contacts
opportunities_cstm

Still no luck on finding the subpanel in the db? Any ideas of where it may be located? Thanks!!!

MariaDB [suitecrm]> show columns from opportunities;
±-----------------±-------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±-----------------±-------------±-----±----±--------±------+
| id | char(36) | NO | PRI | NULL | |
| name | varchar(50) | YES | MUL | NULL | |
| date_entered | datetime | YES | | NULL | |
| date_modified | datetime | YES | | NULL | |
| modified_user_id | char(36) | YES | | NULL | |
| created_by | char(36) | YES | | NULL | |
| description | text | YES | | NULL | |
| deleted | tinyint(1) | YES | | 0 | |
| assigned_user_id | char(36) | YES | MUL | NULL | |
| opportunity_type | varchar(255) | YES | | NULL | |
| campaign_id | char(36) | YES | | NULL | |
| lead_source | varchar(50) | YES | | NULL | |
| amount | double | YES | | NULL | |
| amount_usdollar | double | YES | | NULL | |
| currency_id | char(36) | YES | | NULL | |
| date_closed | date | YES | | NULL | |
| next_step | varchar(100) | YES | | NULL | |
| sales_stage | varchar(255) | YES | | NULL | |
| probability | double | YES | | NULL | |
±-----------------±-------------±-----±----±--------±------+

That subpanel is driven by this bit of defs:

It will generate a query that gathers data from all those tables - meetings, tasks, calls, notes, emails.

And the emails seem to be referencing this

Thanks pgr. I wrote a query to get the information from my database in a certain table/row but it isnt exactly giving me what I want. #query the name row in the opportunities table
$sql = “SELECT * FROM opportunities WHERE name = ’opp name (I used a real name)’;

$store the result in a variable and dbc is the database connector
$result = mysqli_query($dbc, $sql) or die(“Query Failed, try again $sql”: );

?>

You said that from the history array it will build a query? Is there a way to find the query being generated as I am having trouble writing my own. Thanks!

I also went into vim /var/www/html/SuiteCRM/config.php and went to

‘hide_history_contacts_emails’ =>
array (
‘Cases’ => false,
‘Accounts’ => false,
‘Opportunities’ => true,
),

Opportunities was originally set on false and I changed it to true, then restarted the httpd service on our linux box. Unfortunately, this only hid the emails the emails of contacts under the contacts panel. I think I found the query you were talking about

function get_unlinked_email_query($type, $bean)
{
global $current_user;

$return_array['select'] = 'SELECT emails.id ';
$return_array['from'] = 'FROM emails ';
$return_array['where'] = '';
$return_array['join'] = " JOIN (select DISTINCT email_id from emails_email_addr_rel eear

    join email_addr_bean_rel eabr on eabr.bean_id ='$bean->id' and eabr.bean_module = '$bean->module_dir' and
    eabr.email_address_id = eear.email_address_id and eabr.deleted=0
    where eear.deleted=0 and eear.email_id not in
    (select eb.email_id from emails_beans eb where eb.bean_module ='$bean->module_dir' and eb.bean_id = '$bean->id')
    ) derivedemails on derivedemails.email_id = emails.id";
$return_array['join_tables'][0] = '';

if (isset($type) and ! empty($type['return_as_array'])) {
    return $return_array;
}

return $return_array['select'] . $return_array['from'] . $return_array['where'] . $return_array['join'];

}

to run it do I just enter get_unlinked_email_query($type, $bean) and put in parameters while the log is in debug mode? Thanks!

@pgr So I believe he root cause is that the history panel is not limiting to the correct opportunity instead of random emails being populated. After looking through all the php code you sent me, and rebuilding the relationships, the code remained the same and everything seems correctly linked together. What could be the cause of the history subpanel displaying multiple opportunities? I do see each email is associated with a single opportunity. The history panel is not limiting to the correct opportunity