0

Node has two fields:

  1. Text field
  2. Term reference field (autocomplete?)

The Text field is old and already has 500 nodes with 500 unique values.

The Term reference field is new and needs to contain same data.

So e.g. one node has Text field value of 123, the Term reference field also needs somehow to have it set to 123?

enter image description here

In Rules Set a value data only lets you copy content from term reference field into text field, but not vice versa.

Or on page save it does save a new term based on text field to the taxonomy vocabulary, but the term itself does not show up/gets saved in the node/its term field?

Rule in the making:

enter image description here

Under Actions we select Set a data value and in first screen we select our Taxonomy term reference field that needs to be modified:

enter image description here

And then on a next screen we are stuck, because we cannot select the source for data selector which is a Text field but all available options are only other Term reference fields.

The missing field is added under Conditions with Entity has field (the node:field-enter-product-name-)

3
  • If the whole point is to delete the text field and start using an entity reference field, then I would just export those two tables only as CSV file, and copy over the text field and values to the entity reference table and the node id, like I mention here.
    – No Sssweat
    Aug 5 at 0:53
  • Alternatively, you could use views_data_export module and export as text field as CSV and then import into the entity reference field using the feeds module
    – No Sssweat
    Aug 5 at 0:53
  • @NoSssweat the text field will not be deleted, it will be used for data entry as it was, it's just that data will be copied to the term reference field too (on save?). How do Feeds import CSV with correct terms into correct nodes exactly? Aug 5 at 1:19
2
+50

This works for D7

Term reference field (autocomplete?)

in rules, widget does not affect, you just set values, but leave it as autocomplete, a select list cosumes more resourses

The Text field is old and already has 500 nodes with 500 unique values.

Unique values, this means one unique taxonomy term for each node.

The Term reference field is new and needs to contain same data.

Your taxonomy term title value it will hold the field value

Your events on node: new/update are ok

On your conditions i can't tell mutch, img is not complete, i sugest to include 'field data value IS empty' on your node taxonomy term rerefence field. This will avoid to create duplicate terms and updating same node twice.

Steps:

1.- In actions secction add an accion

2.- create a new entity (term must exist to be assigned as TR to a node by rules)

3.- select from dropdown: taxonomy term

4.- for term name select node title, avilable in data selector mode

5.- select your taxonomy vocavulary

6.- change (optional) variable name and hit save

7.- add another accion: save entity, the new term

8.- add aonther accion: set a data value

9.- now select your updated node and drill down to find term reference field

10.- and set node field value with the term reference you just created

11.- save node, done

EDIT:

Steps to buit a component:

this way you can call it from node/new event or from a VBO to update all old nodes

a.- add a component of type RULE

b.- in parameters seccion add parameter type: node, label: product node, machine name:product_node, save settings

c.- on conditions add: entity has field (your product node): select your term reference field

d.- add another condition: your term reference field is empty

do all accions steps explainded above in rule, now you can call your component any where.

7
  • Hi @pinueve , this saves new taxonomy term to the vocab, but it doesn't save the term into the node. Aug 6 at 14:21
  • I edited my answer, i just added numbres, nothing else, and YES, it does save term into the node (accions 8, 9, 10, 11)
    – pinueve
    Aug 6 at 15:25
  • I have recorded my setup and demonstration can you please review streamable.com/v138c1 Aug 6 at 15:39
  • 1
    nice recording, i did not new that app, thanks, you are missing step 7, is needed, i mensioned on step 2, now you will have 2 save actions, one for term, one for node, and please DO select in these 2 actions: force save entity to true, i.imgur.com/PKriyCA.png
    – pinueve
    Aug 6 at 15:54
  • 1
    and i recomend you to do it by a component, this way you can call your component from your rule, or by VBO to update all existing nodes, and please follow order in actions explained
    – pinueve
    Aug 6 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.