I’ve been learning a lot about express lately as I’m trying to use it on a project. My problem is that I’m getting getting an error: “Entity of type Concrete\Core\Entity\Attribute\Value\ExpressValue is missing an assigned ID for field ‘attribute_key’. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.”
The code causing the error is:
$activityLog=Express::buildEntry(‘ravid_contact_activity’);
$activityLog->setRavidCrmActivityDateTime(new \DateTime());
$activityLog->setRavidCrmActivityNotes(‘Created new Member, user not notified’);
$activityLog->setRavidCrmActivityAssociation($contact);
$activityLog->save();
I’m trying to create a ravid_contact_activity entry then associate it to a contact.
I’m also not sure that’s the right way to associate but was trying it.
I’m not entirely sure here, but an issue might be that the entry builder is a “builder” pattern, where it returns an object as is meant to have the various set methods be chained together. Here you’re running all the →set(…) methods on the same instance of the original object, instead of on one that is returned from each method call. Does it work if you change your code to this? :
$activityLogEntry = Express::buildEntry(‘ravid_contact_activity’)
->setRavidCrmActivityDateTime(new \DateTime())
->setRavidCrmActivityNotes(‘Created new Member, user not notified’)
->setRavidCrmActivityAssociation($contact)
->save();
Andrew i’ll try it.. They should be syntactically equivalent as the only reason the chained methods work is they return the object itself.
I ended up breaking the association and moving the log to an independent table which is probably for the better anyway after working through some of the details. Having it bundled as part of express would’ve been a little messy.