Express Error: Value is missing an assigned ID for field 'attribute_key'

v8.5.12

Exception Occurred: /home/fcwork/public_html/concrete/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:87 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. (0)

I receive this error on the $jgEntry->save() of Express::buildEntry(‘journey_grp’);

I even created a new parrallel Express dataobject for testing since I started using Express back in the early v8 versions. That did not fix the problem. Trying this was based on the following references.

Here is my code which I have been running and testing the just created v8.5.12 journey_grp dataobject and on the old original journey_group dataobject. I have created other similar dataobject entries successfully which have User Select fields and Associations.

$jgEntry = \Express::buildEntry('journey_grp');
if ($jgEntry) {
	$jgEntry->setAttibute('journey_grp_member_id',$userId); // User Select
	$jgEntry->setAttibute('journey_grp_member_name',$userNameOrig);
	$jgEntry->setAttibute('journey_grp_name',$groupName);
	$jgEntry->setAttibute('journey_grp_number',99);
	$jgEntry->setAttibute('journey_grp_short_desc','');
	$jgEntry->setAttibute('journey_grp_long_desc','');
	$jgEntry->setAttibute('journey_grp_leader_info','');
	if ($isLeader) {
		$jgEntry->setAttibute('journey_grp_is_leader',1);
	} else {
		$jgEntry->setAttibute('journey_grp_is_leader',0);
	}
	$jgResult = $jgEntry->save();
	if ($jgResult) {
		// --- Add Associations ---
		$jgResult->associateEntries()->setLabelHub($labelHub);
		$jgResult->associateEntries()->setLeaderOne($leaderOne);
	}
	return true;
}

looks a bit like a bug noted when trying to import csv datas, see Import csv datas in express

I already successfully use the same Concrete CMS documentation to create new Entries like my first example in three other Data Objects.

This one, and 2 other similar ones, work:

$coach = \Express::buildEntry('coach');
$coach->setAttribute('coach_member_id', $userCoachTmpID);		// User Select
$coach->setAttribute('coach_for_participant_id', $userCurID);	// User Select
$coach->setAttribute('coach_member_name', $tmpCoachName);
$coach->setAttribute('coach_participant_name', str_replace(' ','_',$rrName));
$savedCoach = $coach->save();
if ($savedCoach) { 
	$savedCoach->associateEntries()->setLabelHub($labelHub);
}

I was planning on doing what you tried to do with the CSV data which I can export from the Express dashboard. I was going to transfer all the existing data from the journey_group dataobject to the journey_grp dataobject and then delete the old one and rename the new one. This was assuming that creating the new journey_grp dataobject would solve my problem. It did not.

Here is another related post:

Also, I am having troubles finding the correct “use” statements to have PHP recognize associateEntries()

$jgEntry->associateEntries()->setLabelHub($labelHub);
$jgEntry->associateEntries()->setLeaderOne($leaderOne);

Error: Call to undefined method Concrete\Core\Express\EntryBuilder::associateEntries()

This doesn’t make sense. associatedEntries() is in

/concrete/src/Entity/Express/Entry.php

and the entry stuff is in

/concrete/src/Express/EntryBuilder.php

I ran diagnostic tests of the successful and failed saves of two different Express dataobjects. My discoveries so far for the FAILED save:

  1. attribute is not being set
  2. __call() is being referenced but not on successful save

SUCCESSFUL save for Express dataobject “coach”

“Mar 14, 2023, 10:04:35 PM”,
INFO,Application,admin,“ObjectTrait.php :: setAttribute()[76] parameters :: $ak:coach_member_id | $value:3 | $doReindexImmediately:1”

“Mar 14, 2023, 10:04:35 PM”,
INFO,Application,admin,“EntryBuilder.php::save() [75] $key:coach_member_id | $value:3”

“Mar 14, 2023, 10:04:35 PM”,
INFO,Application,admin,"EntryBuilder.php::save() [73] attributes: Array
(
[coach_member_id] => 3
[coach_for_participant_id] => 3
[coach_member_name] => John_Doe
[coach_participant_name] => John_Doe
)
"
**** SUCCESSFULL save has no references to: EntryBuilder.php::__call() ****


FAILED save for Express dataobject “jounrney_group”

  1. attribute is not being set
  2. __call() is being referenced but not on successful save

“Mar 13, 2023, 10:30:14 PM”,
INFO,Application,admin,“ObjectTrait.php :: setAttribute()[76] parameters :: $ak:attibute | $value:journey_grp_is_leader | $doReindexImmediately:1”

“Mar 13, 2023, 10:30:14 PM”,
INFO,Application,admin,“EntryBuilder.php::save() [75] $key:attibute | $value:journey_grp_is_leader”

“Mar 13, 2023, 10:30:14 PM”,
INFO,Application,admin,"EntryBuilder.php::save() [73] attributes: Array
(
[attibute] => journey_grp_is_leader
)
"
“Mar 13, 2023, 10:30:13 PM”,
INFO,Application,admin,“EntryBuilder.php::__call()[52] $identifier:attibute”

“Mar 13, 2023, 10:30:13 PM”,
INFO,Application,admin,"EntryBuilder.php::__call()[47] nm:setAttibute | a:Array
(
[0] => journey_grp_member_id
[1] => 1
)
"
“Mar 15, 2023, 1:20:53 PM”,
INFO,Application,admin,“EntryBuilder.php::__call()[52] $identifier:attibute”

“Mar 15, 2023, 1:20:53 PM”,
INFO,Application,admin,"EntryBuilder.php::__call()[47] nm:setAttibute | a:Array
(
[0] => journey_grp_member_name
[1] => John_Doe
)
"

Bottom line for the FAILED tries versus the SUCCESSFUL tries:

EntryBuilder.php::setAttribute() is NOT being called on the FAILED tries

Instead the __call magic method is called.

EntryBuilder.php::__call() | $name:setAttibute | $arguments:Array
(
[0] => journey_grp_member_id
[1] => 3
)

Why is EntryBuilder.php::setAttribute NOT being called?

ANSWER: Whenever you see “missing an assigned ID for field ‘attribute_key” check the spelling! I misspelled setAttibute which should be setAttribute. In my case all this for the lack of an “r”.

1 Like