Missing method for retrieving express entry ID from Express Entry Builder
Permalink
Using the code fromhttps://documentation.concrete5.org/developers/express/creating-read... to insert a new express data entry:
Next I need to retrieve the express entry ID from the recently created entry:
This fails as the Express Entry Builder lacks a getID() method...
Wow can I retrieve the express entry ID from the recently created entry?
$entry = Express::buildEntry('student') ->setStudentFirstName('Andrew') ->setStudentLastName('Embler') ->setStudentContactAddress($address) ->save();
Next I need to retrieve the express entry ID from the recently created entry:
$entryId = $entry->getID();
This fails as the Express Entry Builder lacks a getID() method...
Wow can I retrieve the express entry ID from the recently created entry?
I'm also wondering about this. Can anyone help with this?
This is weird. The save() function returns the entry itself which is confirmed by the docs "The $entry object here is the full Concrete\Core\Entity\Express\Entry"
The class Concrete\Core\Entity\Express\Entry does contain a getID() function as well as a jsonSerialize() function that will return an array containing both the entry's label and ID.
Could you do a get_class() on your $entry object to check what class it really is?
The class Concrete\Core\Entity\Express\Entry does contain a getID() function as well as a jsonSerialize() function that will return an array containing both the entry's label and ID.
Could you do a get_class() on your $entry object to check what class it really is?
As expected get_class($entry) returns Concrete\Core\Express\EntryBuilder
That's really strange. As I said the save function really returns the Entry. So let's try something really stupid but you never know it might work.
What do you get if you try
What do you get if you try
$builder = Express::buildEntry('student') ->setStudentFirstName('Andrew') ->setStudentLastName('Embler') ->setStudentContactAddress($address); $entry = $builder->save();
Great solution!. Yes, this works:
In short:
Thank you for great support.
$entry = $builder->save(); $entryClass = get_class($entry); # returns 'Concrete\Core\Entity\Express\Entry' $entryId = $entry->getID(); # returns the new entry ID
In short:
$entryId = $entry->save()->getID();
Thank you for great support.