0

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.

1
  • oh. that is odd that resending gives the correct value
    – petednz - fuzion
    Commented Jul 21, 2023 at 20:24

1 Answer 1

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.

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.