Hi all,
my issue could be related to this one Updating leads after adding fields but since there was no answer on this topic I create this one.
I got a few custom fields in my leads table.
My code which shall to update the fields in the leads table it looks like that:
$entity = $repo->findOneBy( $keyArray );
/*
The following sets a value of my custom field which I added in the Contacts table via
“Settings/CustomFields”
*/
$entity->setCustomfieldvalue(5);
$entity->setFirstName(“anotherName”);/*
The following is a method which is provided by the CustomFieldEntityTrait which is used in the
Mautic\LeadBundle\Entity\Lead class.
It prints out the information that the customfieldvalue has been set!
*/
print_r($entity->getUpdatedFields());
Array
(
[customfieldvalue] => 5
)$this->em->persist($entity);
$this->em->flush();
The problem is that the persist and the flush only store the update of the FirstName field (which is part of the Mautic Lead entity). However the custom field gets ignored.
Does anybody know how what I am doing wrong?
Another useful information might be if I am creating the dataset (so not updating an existing one, but creating a new one) using:
$this->leadModel->saveEntity($entity);
Both fields are set correctly. So really seems to be a problem with the update of custom fields.