I am using service module 7.x-3.12. The index call by node resource provides provides node related data but only from node table. I can't fetch the value from custom fields of a node. So I want to alter the query in index call build by services_resource_build_index_query() function. But I can't find any way to alter the query.

2 Answers 2


You can use rules for this to add custom field or you can use "hook_services_request_postprocess_alter" to add new array with custom field.

Using rule you can set in event "Content is viewed of type .." and in action you need to custom php that returns $node->custom_field = val;


You can use hook_query_alter() to alter any query that uses Drupal's database API.

Example from the docs:

function hook_query_alter(QueryAlterableInterface $query) {
  if ($query->hasTag('micro_limit')) {
    $query->range(0, 2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.