Data comparison of a list field using "is one of" operation does not evaluate correctly

Created on 6 June 2014, about 10 years ago
Updated 26 August 2023, 10 months ago

Data comparison conditions that utilize "is one of" currently trigger what appears to be an Ajax event that replaces the values list with a data selector. In order to tell the condition to compare the saved data with a list of predefined values, it is necessary to "trick" Rules and bypass this Ajax issue. In short, this is accomplished by choosing "equals", refreshing the browser window, and then selecting both "is one of" and your list of values.

I have tested this in a "save new content" rule and it appears to be repeatable. Here are the detailed steps to reproduce:

(Note, I also have Rules List Conditions installed, but I don't think that module is at play here.)

1. Create a new Reaction Rule and add event, "After saving new content of type [your content type name].
2. Add one or more Actions (e.g. send email).
3. Add a Condition.
4. Select "Data comparison" (default) and click Continue.
5. Select your data selector and click Continue.
6. Check "Negate".

The Operators available here are "equals" (default) or "is one of". Initially, while "equals" is selected, a list of values are visible. But for this condition to work, the data selector must *not* equal any of the listed values.

7. Select "is one of" operator.

When the operator is changed to "is one of", the values list is replaced with a data selector field. This appears to be an Ajax error of some kind, and instead it should continue to show a list of values, because selecting a data selector here will result in the condition failing. Instead, we want to be able to point the "is one of" operator to the list of values.

Note that changing the selected operator back to "equals" does not bring back the list of values, or effect any change. This is where we fool the code and get around what appears to be a bug.

8. Refresh your browser window.

Your browser will ask you if you really want to refresh the page. Because some or all of your selections made thus far are stored locally, go ahead and allow the page to refresh.

When the page refreshes, you now have both the "is one of" Value operator *and* the list of values. Drupal displays a warning at the top, "Data selector field is required. Missing configuration for parameter value." Ignore this warning.

9. With "is one of" selected, and your list of values selected (and Negate still checked) click Save.

Rules goes ahead and permits you to save this condition, and the condition will now tell the rule to fire if the saved value does not match any of the values contained in the list you selected in step 10.

Note: The bypass technique described above will only work while creating a new condition, and not while editing a condition.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States silurius

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States ron_s

    Patch in #22 still applies cleanly to the latest 7.x-2.14 version.

  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States ron_s

    Moving back to needs review since I see it still needs tests, although have been using this in production environments for years.

Production build 0.69.0 2024