Error: variable already exists...
| Project: | Rules |
| Version: | 6.x-1.x-dev |
| Component: | Rules Engine |
| Category: | feature request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
When I create a rule, add an action, I put the info I need... it works great. Say this was a "Load Term". Now I have a variable "taxonomy term".
Add some other actions...
Then I want to load another term. That fails with the error "variable already exists" (I don't know the exact error, but that's what it means).
The problem here is that the 2nd time I try to load a term, the system checks that there won't be a clash between variable names. The system takes the name from the array describing the "Load Term" functionality and uses it as is.
What I'd suggest is that instead of using the name as is, it would be to add the rule number at the end. For most actions it probably isn't a problem, but for the "Load Term", since you first have to define the taxonomy, it fails and you are not given a chance to fix the variable name.
So something like: "set variable name to default name + rule #" would solve the problem 99% of the time (the other 1% are people who change the name and somehow the name still clashes with an existing name.)
Another way, if that's easy enough, would be to define the variable name, check whether it is already defined, if so, add a number at the end (i.e. _1). If that also exists, increment the number (i.e. _2). Do so until you find a name that's available.
Thank you!
Alexis Wilke

#1
Yep, that's not so ideal. However for me developing rules2 is now the priority, but feel free to improve it. The last way with appending _2 looks imo better, so I'd prefer that one.
#2
Do you mean that you are "dropping" this rules module and creating a brand new one??
I will look into it and see whether that's difficult to do. 8-)
#3
Not really.. ;) The concept and module API stays but I'm revising it's internal code to be more modular, flexible, straight-forward to use - so that powerful extensions like Lists, Loops can be handled seamless.
Read http://more.zites.net/rules/reactive_rules_for_drupal_have_grown_up
#4
Hello Guys,
I am getting this same issue when trying to add a Load Term action, however, I have not used one in my rule. I did use however a "Add a new term to vocabulary" and "Load a vocabulary".
I am attaching the skeleton of my rule. Essentially it is a terms moderation rule, users can suggest a term for a node which gets saved as CCK text field + node reference in a separate content type. When it is set to published by the admin it executes this:
ON
event After updating existing content
IF
condition Updated content is published
DO
action Load a vocabulary
action Add a new term to vocabulary
action Load a referenced node
action Assign a term to content
Any ideas are appreciated:
The problem is the term is not assigned to the referenced node, I believe because I need to load the term, after it gets assigned to the vocabulary.