Tokens for entity reference field are printed in the format of:
"term name (tid)"
To create the issue:
1) I created a webform named (Favorite Color) with one "entity reference field" for the "taxonomy Color"

2) I configured a "rule" as below:
EVENT
Entity Insert
Webform Submission of type Favorite Color
ACTIONS
Set values to entity variable (Article Variable)
Save Entity Variable (Article Variable)
Below is the configuraion image for the action "Set values to entity variable":
Results:
After submitting the above webform (Favorite Color).
_ New Article node is created. (working)
_ Node Title is set to: "This is new node created using the Business rules module". (working)
for now all is good, However:
_ Node Body field is set in the following format: Taxonomy term (TermID)
See below image for example:
Problem/Question:
How to copy only the VALUE of the taxonomy term ?
for example: Red and not Red (12)
Thank you and best regards,
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | Manage fields - 2023-02-14.png | 21.64 KB | inman |
| #4 | Screenshot from 2018-07-25 09-03-25.png | 24.2 KB | yseki |
| #4 | Screenshot from 2018-07-25 08-56-53.png | 70.98 KB | yseki |
| #4 | Screenshot from 2018-07-25 08-54-37.png | 57.72 KB | yseki |
| #4 | Screenshot from 2018-07-25 08-37-14.png | 44.18 KB | yseki |
Comments
Comment #2
yseki commentedHi C.E.A,
This is the way the module is supposed to work. In order to get the Term name, you need to create a variable, populate with this target_id ID and then use the Variable field value to fill the node body.
Another possibility is to instead of using the * on the token, use the taxonomy name.
Comment #3
c.e.a commentedHi and thank you for your help once again,
I am trying to create a variable using:
1) Value from Entity field variable option, but the entity reference field of the taxonomy Color is not listed between the fields to choose from.
2) Custom Value variable option, and i set its value to
[webform_submission:values:favorite_color:delta:entity:color]
And in the Action:Set values..., i set the body field = {{variable_for_favorite_color_field}} but still got the same result term name (tid)
I tried to use this method as well but setting the body field = [webform_submission:values:favorite_color:delta:entity:color] but still got the same result term name (tid)
Please note the the machine name of the taxonomy vocabulary is: color
Thank you,
Comment #4
yseki commentedI've tried a simplified approach to get what I'm guessing you want...
Create a new vocabulary: Color

Create an rule for "Before saving the entity"

Create an action to change body field using the token [node:field_color:entity:name]:

And as a result, I've got this body when I've saved my article:

I've noticed that is an issue with the HTML tags of the original body, but the taxonomy term name was included correctly...
Later today I'm going to use exactly your process to see what is happening.
Comment #5
c.e.a commentedHi,
What you have tried above also worked for me...
However, what you are doing is taking the value from a field already existed on the node and copy its value to the body field.
But the problem i am having is happening only when trying to copy the value of the field color from webform submission to a newly created article node.
You will have to recreate my above steps in order to find the problem. (Sea the original question above)
A quick summary to recreate the issue:
1) Create a new taxonomy vocabulary Color and add whatever term to it.
2) Create a new webform Favorite Color and then add an entity select element with the machine name favorite_color referencing the Color taxonomy created in the step 1.
3) Create a business rules:
React on the event:
Entity insert
-> Target entity type: Webform Submission
-> Target Bundle: Favorite Color
Actions:
Set values to empty entity variable
Title: This is a test title
Body: [webform_submission:values:favorite_color:delta:entity:name]
4) try to submit the the favorite color webform and check the result's fields for the newly created article node.
Thank you,
Comment #6
jshimota01 commented* removed by creator*
Comment #7
jshimota01 commented200 tests later - every format of webform_submission tokens give me the same result with 1 single exception:
Entity variable: fetched_user_empty_entity_variable field: field_current_location filled with value: |Gate 2 (5) |Gate 2 (5).
|[webform_submission:values:location_select:selected:raw]
|[webform_submission:values:location_select:selected:option_value:raw]
As seen in the dbug result above it - I get 'Gate 2 (5)'
In one case I do get something different:
[webform_submission:values:location_select:raw] returns a 'node:5'.
I just can't seem to isolate only the TID, or target_id to store back into my user table.
is it possible Webform is storing the string result, which limits the stored variable to a string which can't be drilled down further?
Edit : Answer ' yes'. Webform allows changing what entity option value is stored.
Comment #8
jshimota01 commentedComment #9
Damian W commentedWorks for me [webform_submission:values:Your_Taxonomy_Field:entity:name]
Comment #10
inman commented[webform_submission:values:YOUR_FIELD:entity:name] - works
