I'm assuming you're using a rule that looks similar (equal?) to the rule in the accepted answer in that related question, which looks like so:
{ "rules_improved_combination_of_taxonomy_terms" : {
"LABEL" : "Improved combination of taxonomy terms",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_view--article" : { "bundle" : "article" } },
"DO" : [
{ "drupal_message" : { "message" : "[node:field-a][node:field-b]" } },
{ "variable_add" : {
"USING" : { "type" : "text", "value" : "[node:field-a][node:field-b]" },
"PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
}
},
{ "entity_create" : {
"USING" : {
"type" : "taxonomy_term",
"param_name" : "[variable-added:value]",
"param_vocabulary" : "tags"
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "entity_save" : { "data" : [ "entity-created" ], "immediate" : "1" } },
{ "data_set" : { "data" : [ "node:field-c" ], "value" : [ "entity-created" ] } },
{ "entity_save" : { "data" : [ "node:field-c" ], "immediate" : "1" } }
]
}
}
The above rule does not perform any verification if the term [node:field-a][node:field-b]
(= the value that gets stored in "field C") already exists. Instead each time the Rules Actions are triggered (ie each time "an Article is viewed"), it unconditionally creates that term (which may already exist) another time. So that is why you get all those duplicate terms (like helloworld
in your example).
The solution (fix) for that is that you add some extra logic in your rule to only perform the 3rd (= entity_create
) and 4th (= entity_save
of the created term) Rules Action so that those 2 Rules Actions are only performed if the term does not exist yet.
There are basically 2 solutions/approaches to implement such exta logic:
- Use the the Conditional Rules module, which allows to include the equivalent of a Rules Condition within a Rules Action.
- Move those 2 Rules Actions to an appropriate (new) Rules Component, in which you can add the required Rules Conditions. And then in your rule you just call (perform) that Rules Component.
The advantage of the first solution is that the entire logic is contained in a single Rule, though (disadvantage) it requires yet another module.
With either of both solutions, you basically improve this rule with something like "If the term for field C does not exist yet, then let's quickly create it now, so that we can use that term as the value for field C".
Easy enough, no? ... All you need to know is how to actually perform a check in Rules to verify "If that term is already contained in the list of terms of your taxonomy". That's what you can do with "List contains item", with list
= the terms that exist before the rule starts executing, and item
the term [node:field-a][node:field-b]
.