# Getting a contact's name

**URL:** https://forum.mautic.org/t/getting-a-contacts-name/5260
**Category:** Development
**Created:** [September 7, 2016, 9:32pm UTC](https://forum.mautic.org/t/getting-a-contacts-name/5260 "2016-09-07T21:32:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![floorbeads](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@floorbeads](https://forum.mautic.org/u/floorbeads)
#### Post date: [September 7, 2016, 9:32pm UTC](https://forum.mautic.org/t/getting-a-contacts-name/5260/1 "2016-09-07T21:32:36Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![floorbeads](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@floorbeads](https://forum.mautic.org/u/floorbeads)
#### Post date: [September 7, 2016, 9:32pm UTC](https://forum.mautic.org/t/getting-a-contacts-name/5260/2 "2016-09-07T21:32:36Z")

</div>

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:

```auto
->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?
