How to retrieve a select box option and set the field's value to it? I have a a taxonomy term select box (called "product_keyword") in a node that gets its options populated via the Reference Field Option Limit module. There are 3 other taxonomy term reference fields in the node that are responsible for limiting the "product_keyword" option list all the way down to a single option, and this part is working beautifully. 

The "product_keyword" field is set to Required, so when you actually go in to edit the node, the "product_keyword" field appears to already have this one option selected. However, with the use of the Devel module, I have discovered that this is not the case. There is no #value for the "product_keyword." I have created a custom module (my very first one ever, in fact) to set this #value, but I am having trouble determining how to choose the right properties to set this. This response by Clive is what I'm trying to wrap my brain around.

My module code is using a hook_form_alter function that involves the use of #after_build:

    //Declare the callback for after_build for page node form
function set_keywords_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'part_node_form') {
    $form['#after_build'][] = 'set_keywords_after_build';
  }
}

function set_keywords_after_build($form, &amp;$form_state) {


The overall goal is to simply allow this field to be displayed in a view, but one complication is that these 7000+ nodes are being imported via the Feeds module, and the clients should not have to edit each node manually just to hit the Save button (which is the only way the problem can be solved now - VBO can't do it, nor can the Resave Nodes module). I'm not even sure if #after_build should be involved, and I am also ok with setting the field's #default_value instead of or in addition to the #value.

EDIT:

In the page array dropdown, for the keyword's select list options: 

#options (Array, 1 element) 0 (String, 13 characters ) Inker Parts 


But under '#value," I'm just getting: 

#value (String, 8 characters ) - None - 


Under another reference field, "Product Family," where things are functioning normally, I see: 

#options (Array, 40 elements) 
_none (String, 8 characters ) - None - 
1401 (String, 5 characters ) AUTOZ


.......and so on 

and for the #value: 

    0 (String, 2 characters ) 1401 
          $...['content']['system_main']['field_product_family']['und']['#value'][0] 


In this example, "1401" is the tid, and "AUTOZ" is the term name.
This question looks a little old, but here is an answer for you.  Reading your comments you have 

//Declare the callback for after_build for page node form
function set_keywords_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if ($form_id == 'part_node_form') {
        $form['#after_build'][] = 'set_keywords_after_build';
    }
}

function set_keywords_after_build($form, &amp;$form_state) {
    $keyword = $form['field_product_keyword']['und']['#options']; 
    $form['field_product_keyword']['und']['#value'] = $keyword;
    $form['field_product_keyword']['und']['#default_value'] = $keyword; 
    return $form; 
}


I applaud your efforts, especially that you are attempting to do this clean and proper with a hook_after_build.  The hook_after_build allows your value setting code to run after the Reference Field Option Limit has done its adjustments, so you are certain to be getting the value you want.
I see one mistake in your code, and that is that #options is an array of Label => Value so that the form can display language in the select field instead of raw values.  I think all you need is this one adjustment:

// remove the -None- option from the start, then set the next option
array_shift($form['field_product_keyword']['und']['#options']);
$keyword = array_shift(array_keys($form['field_product_keyword']['und']['#options']));
// this is safe because $form is not passed by reference, 
// do not do this on $form_state


When trying to do things like this, I find it helpful to look inside what it is I am manipulating.  If you know the string of references that you need to access some data, you can print it on the form like this:

//Declare the callback for after_build for page node form
function set_keywords_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if ($form_id == 'part_node_form') {
        $form['#after_build'][] = 'set_keywords_after_build';

        // see what our options are, print them as text on the form:
        $form['some_text'] = array(
            '#markup' =&gt; '&lt;p&gt;'. $form['field_product_keyword']['und']['#options'][0] .'&lt;/p&gt;',
            '#weight' =&gt; '-80'
        );
    }
}


As you have mentioned you are using the devel module, you could easily throw the #options array into a dpm() or krumo() inside the form alter and get it printed to your form page also.