I am attempting to use the entity-field-query API to see if any node of referee content type has custom field that equals x. I've looked at dozens of code examples and references. (Included below)
If it is relevant I am executing this code as a custom PHP action in Drupal rules.
My problem is when the code is executed I get the below error:
EntityFieldQueryException: Unknown field: field_referee_id in EntityFieldQuery->addFieldCon dition() (line 817 of /home/scienceorg/public_html/includes/entity.inc).
(The field does exist on the referee content type.)
<?php error_reporting(E_ALL); $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'referee') ->fieldCondition('field_referee_id', 'value', '1', '='); $result = $query->execute(); ?>
Further information: If I remove the field condition line from the above code it works perfectly. So the problems seems to be around finding the field_referee_id.
Code references and examples
Alternative answer: If you don't know what is causing the above problem I will accept alternative methods of achieving the same outcome as the correct answer.