Mautic Community Forums

Getting a contact's name

I am struggling to grab the contact’s name.

Code:
$contact->getLead()->getId()
displays the contact's ID.
Code:
$contact->getLead()->getName()
is blank. No errors.
Code:
$contact->getLead()->getPrimaryIdentifier()
is Anonymous, but it's not an anonymous lead.

In the entity, I've tried to add a join:
Code:
->addJoinColumn('lead_id', 'firstname', true, 'CASCADE')

Which yields:
Quote:
mautic.NOTICE: PHP Notice: Undefined index: firstname - in file ..mauticvendordoctrineormlibDoctrineORMUnitOfWork.php - at line 2649 [] []
mautic.CRITICAL: Uncaught PHP Exception DoctrineCommonProxyExceptionOutOfBoundsException: "Missing value for primary key id on MauticLeadBundleEntityLead" at ..mauticvendordoctrinecommonlibDoctrineCommonProxyExceptionOutOfBoundsException.php line 40 {"exception":"[object] (Doctrine\Common\Proxy\Exception\OutOfBoundsException(code: 0): Missing value for primary key id on Mautic\LeadBundle\Entity\Lead at ..\mautic\vendor\doctrine\common\lib\Doctrine\Common\Proxy\Exception\OutOfBoundsException.php:40)"} []

Any tips on where to go from here?

I am struggling to grab the contact’s name.

$contact->getLead()->getId() displays the contact’s ID.

$contact->getLead()->getName() is blank. No errors.

$contact->getLead()->getPrimaryIdentifier() is Anonymous, but it’s not an anonymous lead.

In the entity, I’ve tried to add a join:

->addJoinColumn('lead_id', 'firstname', true, 'CASCADE')

Which yields:

[quote]mautic.NOTICE: PHP Notice: Undefined index: firstname - in file …mauticvendordoctrineormlibDoctrineORMUnitOfWork.php - at line 2649 [] []
mautic.CRITICAL: Uncaught PHP Exception DoctrineCommonProxyExceptionOutOfBoundsException: “Missing value for primary key id on MauticLeadBundleEntityLead” at …mauticvendordoctrinecommonlibDoctrineCommonProxyExceptionOutOfBoundsException.php line 40 {“exception”:"[object] (Doctrine\Common\Proxy\Exception\OutOfBoundsException(code: 0): Missing value for primary key id on Mautic\LeadBundle\Entity\Lead at …\mautic\vendor\doctrine\common\lib\Doctrine\Common\Proxy\Exception\OutOfBoundsException.php:40)"} []
[/quote]

Any tips on where to go from here?