I need to filter an EntityFieldQuery with a given workflow state, let's say workflow it is state 21 (sid = 21
). Below, the query I am using
$query_formularios_completos = new EntityFieldQuery();
$query_formularios_completos
->entityCondition('entity_type', 'node')
->propertyCondition('type', array(
'evento_agencia',
'evento_energia'
)
)
->propertyCondition('workflow', 21)
->fieldCondition('field_e_expositor', 'target_id', $node_expositor_nid);
$result_formularios_completos = $query_formularios_completos->execute();
When using DEVEL to inspect my node, I can see there is a property ->workflow
, side by side with ordinary properties like ->title
or ->created
. Although I can see it there and I expected to filter only items with workflow state 21, I get a horrid database error when trying to execute the code above. Here is more or less the message I get:
Column not found: 1054 Column 'node.workflow' unknown in 'where clause'
Any ideas on how I should filter an entity query using a workflow state as filter? Maybe what I am trying to do isn'tpossible and I have to actually run a query using db_query and applying the appropriate joins.
workflow
isn't a property (in the sense of an 'entity property') it's a value that the workflow module tacks on to a node object in an implementation ofhook_node_load()
. You either need to run a manual query like you say, or useaddTag()
to add a tag to the query, then usehook_query_TAG_alter()
to alter the query when it's been converted down to a standardSelectQuery
. At that point joining the workflow will be easy