Create a View that redirects to node content based on contextual filter? I've created a view with a contextual filter for 'field_object_id' -> this is a field that the content type has which is unique but it's not the Node ID, these field_object_id's are brought in from a JSON feed.

So I can go to my view page like this:

drupal-site.com/my-view

Which would display a page not found. Then going to:

drupal-site.com/my-view/230

Would load up the content node that has '230' set for 'field_object_id' -> however that content node ID is not 230, I have no idea what it is. It could be 8509.

What I need to do, is set my view to automatically redirect the page to the node that it finds (I would set it to redirect to the first result it finds).

I have Panels installed too, would this be easier to do with Panels or should I look to creating a module?
One way I think of is to to this in a custom menu callback. So you could have an URL /mycallback/[OBJECT_ID] which would redirect to the first node that has the given [OBJECT_ID].

Something like this:

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  $items['mycallback/%'] = array(
    'page callback' =&gt; 'fieldvalue_redirect_callback',
    'page arguments' =&gt; array(1),
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}

/**
 * Custom callback given a object id.
 */
function fieldvalue_redirect_callback($id) {
  $query = new EntityFieldQuery();
  $query-&gt;entityCondition('entity_type', 'node')
  -&gt;fieldCondition('field_object_id', 'value', $id, '=')
  -&gt;addMetaData('account', user_load(1));                            
  $result = $query-&gt;execute();

  if (isset($result['node'])) {
    drupal_goto(url('node/' . key($result['node'])));
  } else {
    drupal_set_message(t('Page not found'), 'error');
    drupal_goto('&lt;front&gt;');
  }
}


First comes the definition of the menu callback, MYMODULE_menu().

The argument after mycallback/ is being passed on the the page callback function by defining it here 'page arguments' => array(1),.

fieldvalue_redirect_callback() will get the id entered by the user after /mycallback as argument. In the function we use EntityFieldQuery to fetch the node that matches the given ID.

And last we redirect if we get a result, otherwise we show an error message and the front page.

Hope this can help you or someone else.