Express Build Entry, setAuthor, maybe giving me problems?

I’m using Concrete CMS v8.5.13 in my dev environment here, and I THINK my problem is in how I’m trying to set the Author ID, but if that is the case I’m not sure how I should do it.

I’m doing

$entry = Express::buildEntry(‘express_object_handle_goes_here’)
->setAuthor($userIDVariablePreviouslySet)
->setAnotherAttribute($variableWhatever)
->save();

I’m pretty sure this step in my code (because the debug output is unclear about the problematic line) is producing this 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.”

So… am I barking up the right tree? And if so, what should I be doing instead?

Thanks! :slight_smile:

I suppose I’m most interest in defining setAuthor() when building an Entry in scenarios where I want to use Author for various identity purposes, but in scenarios where at the time of the Entry creation I want the Author to be set to a user that is not who is logged in at the time (for intentional and “good” purposes, not tampering or whatever).

Hmmmm :thinking::thinking::thinking:

Well if I don’t declare setAuthor it by default is the logged in user. Really would prefer not to have to break this out into two steps if I want an Author different from the user logged in. Anyone have any ideas on how to make that happen?

You might try updating to the latest version of 8, or 9. It’s tough to troubleshoot older versions because your issue might be fixed in later ones.