Contact Emails Only Show Up After an Edit & Save

Did the self hosted migration from V4 to V5 which went well with no errors and all the data seems to be there. But the emails do not display under the client list or in the reports. The emails are there in the client page and if I click edit then save the on the client page the emails show both in the reports and the display.

Hi,

@david any thoughts?

The app uses the contact.is_primary field to determine which email to show in the tables. If there are no primary contacts it could explains this behavior as saving the client would set the primary which would correct it.

That makes sense, maybe there is some SQL that would set that for all the contacts that have emails so I don’t have to click through about 800 contacts.

@lawrencesystems

From the command line can you try:

php artisan ninja:check-data --fix=true

This should set the primary contact.

1 Like

That did not solve the contact issue but it did work to solve a few other errors I did not know about.

2022-09-21 11:14:13 2022-09-21 11:14:13 Running CheckData... on Connected to Default DB Fix Status = Fixing Issues
2022-09-21 11:14:13 0 clients with incorrect balances
2022-09-21 11:14:13 REDACTED id = # 14148 - Client Paid To Date = 0.000000 != Invoice Payments = 129 - 129.000000 + 
2022-09-21 11:14:13 REDACTED id = # 14649 - Client Paid To Date = 0.000000 != Invoice Payments = 2 - 2.000000 + 
2022-09-21 11:14:13 2 clients with incorrect paid to dates
2022-09-21 11:14:13 0 contacts without a contact_key
2022-09-21 11:14:13 0 clients without any contacts
2022-09-21 11:14:13 0 contacts without a contact_key
2022-09-21 11:14:13 0 vendors without any contacts
2022-09-21 11:14:13 0 invoices without any invitations
2022-09-21 11:14:13 0 quotes without any invitations
2022-09-21 11:14:13 0 credits without any invitations
2022-09-21 11:14:13 0 recurring_invoices without any invitations
2022-09-21 11:14:13 0 wrong invoices with bad balance state
2022-09-21 11:14:13 0 users with duplicate oauth ids
2022-09-21 11:14:13 Done: FAILURE
2022-09-21 11:14:13 Total execution time in seconds: 0.18414807319641

I’ll need to look into why the migration didn’t set a primary contact. In the meantime if you are keen to get a fix for this run the following:

php artisan tinker

then paste the following

App\Models\Client::with('contacts')->cursor()->each(function ($client){

  $contact = $client->contacts->sortByDesc('is_primary')->first();
  $contact->is_primary = true;
  $contact->save();

});

Then back in Invoice NInja go to Settings > Device Settings > Refresh data

The contact emails will then show in the client list.

1 Like

Perfect, that fixed it! Thanks!

1 Like