how to set a webform field value in my custom module drupal 7 webform 7-3.18

My webform has a hidden field used to store an unique id. This id is generate from custom logic.

my code is to set this field value. 
'webform_client_form_1' is my webform id

function webform_custom_form_webform_client_form_1_alter($form, $form_state, $form_id) {
  $form['submitted']['test_id']['#value'] = 'COURSE_ID-123456';      
}


When the form is submitted and view the submission result and this hidden field value is empty
Ok, try not to confuse Webform module stuff with core drupal FAPI stuff.

You cannot set $form['submitted']['test_id']['#value'] = 'COURSE_ID-123456'; in the form_alter because $form is not passed in by reference and the submitted key values is set after the form is POSTed to my knowledge.

So you're trying to put stuff into the form in the wrong time and place. If I was just using FAPI and not webform. I would not use a "hidden" form value (which isnt really hidden on the page), but use Form build_args or $form_state['MYMODULE_temporary'] to hold my custom course_id in the FAPI form lifecycle so that the client never sees these values, but they are passed along through form validation and submission.

You can probably do the same technique I describe above and then implement hook_webform_submission_insert(), or hook_webform_submission_update() (if your form supports Drafts) to perform submission logic and look at your custom course_id stuff ...