0

I want to set up a rule which would create a product when the user saves a submission form. The submission form is embedded into a simple node (using entity reference) presenting the "product" being sold. What I would like to do is to use information from that node when the rule creates the product.

The problem I am having is that I cannot find any valid way to get these fields to display in rules' data selector. The only way I found was to add the event "content is viewed" in addition to the event "after saving a new entityform". But I only want to keep the event related to the submission form.

So my question is the following: how can I display the fields contained in the node being viewed in rules' data selector without using this event? Thanks in advance for you help!

  • This submission form which you mention, is it a custom module? An implementation of hook_form_alter()? – Wtower Jul 11 '14 at 8:39
  • The submission form is set up using the module Entityform... – Igor Jul 11 '14 at 9:57
0

It depends on the implementation of this submission form, but a common way to expose fields in Rules is to add a condition 'Entity has field' in your rule.

In your particular case, you would select node as entity and the particular entity reference field.

In this way the rule will only execute if the node indeed has this field, and also will allow you to use the field in your actions below.

  • That's exactly what I've been trying to do but if I remove the event "content is viewed", I cannot select "node" in the condition's data selector. And if I do try to enter "node", the system tells me "Data selector node for parameter entity is invalid". In other words, it's like a cascade: I have to add a condition to display the fields I need in the actions' section but first I need to select an event involving the node containing these fields in order for this node to be accessible in the conditions' section (which is not what I want). Hope it's not too confusing put that way...thanks a lot! – Igor Jul 11 '14 at 9:56
  • Maybe then you could break your rule in two parts by using a rule component? – Wtower Jul 11 '14 at 9:57
  • It was a good idea but I eventually face the same problem. I set up a component (for actions) and added it to my initial rule. However, when adding it, the system requires to enter all the fields again, which I cannot do for the reasons mentioned above. Again, thanks a lot for the suggestion! – Igor Jul 11 '14 at 10:40
  • Sorry but I can't precisely understand the problem. Is it that Rules don't know the exact Node ID that was active when the event was triggered? In this case I would write a small custom module, define a custom rules event with hook_rules_event_info(). Then use hook_form_alter() to define another custom submit function, in which manually invoke this event and call the original submit handler. – Wtower Jul 11 '14 at 12:01
  • Yeah sorry for the lack of clarity... The problem is not that Rules doesn't know the exact Node ID, the problem is that most fields that I need in order to set up my Actions are not available in the Data Selector. And I cannot add a condition (e.g. the entity contains such field) without first adding an event involving the node containing the fields I need (which I do not want to do). Anyway, I don't want to waste more of your time, thanks again for your efforts, greatly appreciated! – Igor Jul 11 '14 at 13:51

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.