Answers.Body: <p>I’ve not found a way of getting Drupal/CiviCRM to populate the email token with the text of the State/Province.  It always comes out as the index number.</p>
  <p>However, I’ve figured out a workaround.  I’ve added a text field to the Webform and I then hide the field from the user.  I then run some JavaScript to copy the value of the CiviCRM State/Province field into the hidden field.  This gives me the text for the selected item.  I then use that field id in the email instead of the CiviCRM field id.</p>
  <p>Happy to share the JavaScript code but I'm new to StackExchange and I don't know how to do this.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-22T06:20:25.193Z
Answers.LastActivityDate: 2023-07-22T06:27:35.007Z
Answers.LastEditDate: 2023-07-22T06:27:35.007Z
Answers.UserDisplayName: tomodea
Body: <p>I have a problem with one of the fields in a notification email for CiviCRM Webforms.</p>
  <p>I’m using a Drupal Webform which includes CiviCRM contact fields.  These fields include a number of fields that make up the postal address.</p>
  <p>One of these fields is the State/Province.  The key is: civicrm_1_contact_1_address_state_province_id</p>
  <p>I’ve included that field in the Webform email: [webform_submission:values:civicrm_1_contact_1_address_state_province_id]</p>
  <p>The problem is that when the email is sent, the value for the State/Province is shown as “1644” instead of “Victoria”.</p>
  <p>All the other Webform submission values in the email are correct.</p>
  <p>This was working as expected under Drupal 7 but we recently migrated to Drupal 9 and we are now seeing the wrong value for the State/Province.</p>
  <p>The strange thing is that if we do a resend of the email, the correct value is shown.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-21T20:24:11.583Z
Comments.Text: oh. that is odd that resending gives the correct value
Comments.UserDisplayName: petednz - fuzion
Tags: <webform-civicrm><email><tokens>
Title: CiviCRM Webforms - Webform submission value shows the field id instead of the value of the id
ThreadText: # CiviCRM Webforms - Webform submission value shows the field id instead of the value of the id
  
  (Asked by: username_0 on 2023-07-20)
  
  I have a problem with one of the fields in a notification email for CiviCRM Webforms.
  
  I’m using a Drupal Webform which includes CiviCRM contact fields. These fields include a number of fields that make up the postal address.
  
  One of these fields is the State/Province. The key is: civicrm\_1\_contact\_1\_address\_state\_province\_id
  
  I’ve included that field in the Webform email: [webform\_submission:values:civicrm\_1\_contact\_1\_address\_state\_province\_id]
  
  The problem is that when the email is sent, the value for the State/Province is shown as “1644” instead of “Victoria”.
  
  All the other Webform submission values in the email are correct.
  
  This was working as expected under Drupal 7 but we recently migrated to Drupal 9 and we are now seeing the wrong value for the State/Province.
  
  The strange thing is that if we do a resend of the email, the correct value is shown.
  
  **Tags:** webform-civicrm, email, tokens
  
  > **Comments:**
  > **username_1**: oh. that is odd that resending gives the correct value  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-07-22. Score: 2
  
  I’ve not found a way of getting Drupal/CiviCRM to populate the email token with the text of the State/Province. It always comes out as the index number.
  
  However, I’ve figured out a workaround. I’ve added a text field to the Webform and I then hide the field from the user. I then run some JavaScript to copy the value of the CiviCRM State/Province field into the hidden field. This gives me the text for the selected item. I then use that field id in the email instead of the CiviCRM field id.
  
  Happy to share the JavaScript code but I'm new to StackExchange and I don't know how to do this.
  
  
  ---
  
  