4

How can I set a taxonomy term reference field to two values using Rules? The "Number of values" for the field is already set to two.

I set up a workflow in rules that works for setting a single value. I tested this several times and encountered no problems. However, when I changed the "Number of values" for the field from "1" to "2" and then edited the action to add two terms instead of just one, I got the following error message:

  • Warning: Missing argument 2 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of /srv/bindings/e87a1e62cfd24fea9dd67cfd074d146c/code/modules/taxonomy/taxonomy.module).
  • Warning: Missing argument 3 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of /srv/bindings/e87a1e62cfd24fea9dd67cfd074d146c/code/modules/taxonomy/taxonomy.module).
  • Warning: Missing argument 4 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of /srv/bindings/e87a1e62cfd24fea9dd67cfd074d146c/code/modules/taxonomy/taxonomy.module).

When I attempt to set a value by triggering the rule, it fails and the rules debug log has the following output:

  • 3.235 ms Unable to get a data value. Error: Invalid data value given. Be sure it matches the required data type and format.
  • 4.254 ms Unable to evaluate action data_set.

What is the correct way to assign two terms at once to a single taxonomy term reference field?

3
  • Are you using the "Set a data value" action with a comma separated list of taxonomy term ids to set the value?
    – Clive
    Jun 17, 2012 at 17:06
  • I am using the "Set a data value" action with "Direct input mode" to select two values from the select list of taxonomy terms. Jun 17, 2012 at 22:26
  • Please, export your rule and show it here.
    – kalabro
    Jun 21, 2012 at 14:45

2 Answers 2

2

As it turns out, this is actually fairly easy to do in Rules. By updating to the latest version of the Entity API (rc3-- I was stuck on rc1 due to a different bug that I resolved earlier today) with Rules 2.1, I was able to do this in the following way:

  1. Choose the action "Set a data value".

  2. Choose the taxonomy term reference field to set.

  3. Control-click to select the taxonomy terms to add.

That's all there is to it, but there is one potential gotcha: these values didn't always save correctly for me. This may be because I opened multiple tabs in Firefox and tried to save many different rules at once; for whatever reason, sometimes only one of the two values got saved. I fixed this by simply checking all the values again manually and re-saving them until the values stuck.

1

Elaborating on @Patrick Kenny's step #3.

You may need to click the button "Switch to the direct input mode" button to reveal the terms available in your taxonomy field.enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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