Entity reference displays only the ID in the computed twig field

Created on 19 January 2024, 11 months ago
Updated 22 January 2024, 11 months ago

Hello everyone,

We have a webform with a list of doctors in a select field with "doctor's name - department."

We use two "computed twig" fields to separate the doctor's name from the department and store both pieces of information in separate fields in our CRM.

Computed twig - Doctor's name
{% if data.doctor_dept is not empty %}
{% set doctor = data.doctor_dept|split(' - ')[0] %}
{% else %}
{% endif %}
{{ doctor }}

Computed twig - Department
{% if data.doctor_dept is not empty %}
{% set dept = data.doctor_dept|split(' - ')[1] %}
{% else %}
{% endif %}
{{ dept }}

This process works perfectly.

However, we have an optimization request for this process by registering the list of doctors in a content-type. I created a view with an "entity reference" using the fields "doctor's name" and "department" to be used in an "entity reference" field in a web form, replacing the current select.

However, when querying the information stored by the computed twig fields, only the ID of the content type is stored. Is it possible to store the fields doctor's name and department?

If you need any additional information, I am available.

Thank you!

💬 Support request
Status

Closed: works as designed

Version

6.2

Component

User interface

Created by

🇧🇷Brazil adao.boscolo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adao.boscolo
  • 🇧🇷Brazil adao.boscolo

    Thanks Cilefen.

    I didn't find anything similar to my problem, but I did find a suggestion that helped change computed twig.

    If anyone has a similar problem, follow the field configuration:

    Computed twig - Doctor's name
    {% set doctor = webform_token('[webform_submission:values:view_name:entity:doctor]', webform_submission, [], options) %}
    {{ doctor }}

    Computed twig - Department
    {% set dept = webform_token('[webform_submission:values:view_name:entity:field_dept]', webform_submission, [], options) %}
    {{ dept }}

    I hope it helps!

  • Status changed to Closed: works as designed 11 months ago
Production build 0.71.5 2024