Mautic Community Forums

New Contacts Reports Wrong Fields available

I just tried building a new Report based on Contacts data source. On the Data Tab it “appears” to list several fields multiple times (Address 1, Address Line 1, etc). Unfortunately some of these fields belong to the new Company table and not the Contact table.



If you happen to pick a field from the contact table the report fails with a 500 error due to the field not existing in the table.



Checking the code appbundlesReportBundleModelReportModel.php–>getColumnList() is returning an array with the Company fields with a prefix pf “l” (lead). Just checking if anyone else has seen this and if it’s been reported? (Had a quick search but could’t see anything)



Edit: Further investigation shows that appbundlesLeadBundleEventListenerReportSubscriber.php ->onReportBuilder() is calling

Code:
$this->fieldModel->getEntities();
which returns field that are not in the Lead table. While processing this list, the table alias "l." is added when the field don't belong to that table.

Either of the following fixes it:
Option 1: - Ignore non lead fields
Add the following before line 160 (https://github.com/mautic/mautic/blob/staging/app/bundles/LeadBundle/EventListener/ReportSubscriber.php#L160)
Code:
if ('lead' !== $f->getObject()) { continue; }

Option 2: - Change prefix to suit Company Table
A more comprehensive solution would change the prefix to 'comp.' instead of 'l.' for company fields. (This is what I implemented as a test)

Edit 2: Added bug report #2900

I just tried building a new Report based on Contacts data source. On the Data Tab it “appears” to list several fields multiple times (Address 1, Address Line 1, etc). Unfortunately some of these fields belong to the new Company table and not the Contact table.

If you happen to pick a field from the contact table the report fails with a 500 error due to the field not existing in the table.

Checking the code appbundlesReportBundleModelReportModel.php–>getColumnList() is returning an array with the Company fields with a prefix pf “l” (lead). Just checking if anyone else has seen this and if it’s been reported? (Had a quick search but could’t see anything)

Edit: Further investigation shows that appbundlesLeadBundleEventListenerReportSubscriber.php ->onReportBuilder() is calling $this->fieldModel->getEntities(); which returns field that are not in the Lead table. While processing this list, the table alias “l.” is added when the field don’t belong to that table.

Either of the following fixes it:
Option 1: - Ignore non lead fields
Add the following before line 160 (https://github.com/mautic/mautic/blob/staging/app/bundles/LeadBundle/EventListener/ReportSubscriber.php#L160)

if ('lead' !== $f->getObject()) {
    continue;
}

Option 2: - Change prefix to suit Company Table
A more comprehensive solution would change the prefix to ‘comp.’ instead of ‘l.’ for company fields. (This is what I implemented as a test)

Edit 2: Added bug report #2900