We're working on a custom module where we are creating participant content types programatically. We then have some queries to check for where a participant exists.
However although the field field_participant_email
exists and is defined, the below code results in the error InvalidArgumentException: Field field_participant_email is unknown
.
$query = \Drupal::entityQuery('node');
$query->condition('type', 'participant');
$query->condition('field_participant_meeting', $meeting_id);
$query->condition('field_participant_email', $email);
$ids = $query->execute();
We've tried clearing cache, deleting and re-adding the field to no avail.
Does anyone have any suggestions or experiencing with this type of issue?
Much appreciated.
Update 1
For clarity, I've also checked the following:
- checked the spelling of the field
- deleted all the content types and reinstalled them through features
- tried
$query->condition('field_participant_email_value', $email);
- tried
$query->condition('field_participant_email.value', $email);
Update 2
Looking into the core/lib/Drupal/Core/Entity/Query/QueryInterface.php
interface documentation, it seems that adding a condition against a custom field is not supported. This would explain why the error occurs. However I'm yet to find an alternative. I've also experienced the same error when trying to set the value of the field $node->set('field_participant_email', '[email protected]');
.