2

I've been going crazy trying to figure this out. I think I am close, but seem to be missing something with the rule actions. Any help would be most appreciated.

Background:

I’m trying to create nodes from webforms that will pull in certain fields from the webform, namely, first and last names (text fields), affiliation (from an entity filed), and conference to attend (check box list). The reason for this node content type is to pull the conference registrants names and affiliations into a view that will list on each conference page. The content type for the attendees is called “Conference Participants.” The reason for doing this is so the staff in my department does not have to manually enter each person who register.

Present Status:

I started using this process last year with minor success. That is, I was able to use Rules to take a submitted webform and create a node with the participants last, first name as the title. I set the content type to not publish so either I or the staff members could verify the information and publish. As it now stands, the workflow is:

  • Events - Event: After a webform has been submitted
  • Conditions – Elements: Webform has a name – Parameter: The form id of the submitted form: [form-id: value, Webforms: Summer Conference
  • Actions – Elements:
    • Create a new entity – Parameter: Entity type: Node, Content type: Conference Participants, Title: [data:last_name-value], ..., Author: [node:author] Provides variables: Created entity (entity_created)

Issues:

I have not been able to pull any of the text fields (first and last name) from the webform into the node. For my testing, I’ve created a new “email” text field in the node because it is a standard field with most forms. There is a check box list of conference names in which more than one can be checked. I also have an entity type filed (auto complete) of universities around the world which are not pulling in. I suspect this one may be a bit more complicated since it is an entity type field and I may need to use another type of action, e.g. loop. I should add that there are other fields in the content type (Conference Year and a text box for participants to manually type in an institution that is not listed in the entity filed). I have the conference year checked automatically for 2018 (see screen shot below).

enter image description here

Drupal and Module Background:

  • Drupal 7
  • Rules Module
  • Webform Rules
  • Conditional Rules

What I’ve tested:

• Conditionals

  • NOT an authenticated user
  • Entity has field
  • Set a data value
  • Add a variable (with webform tokens using raw and just the value)

Posts I’ve looked at:

Screen shots

Summer Conference Participant Rule workflow enter image description here

Conditions: Elements: Webform has name enter image description here

Actions: Elements: Create a new entity enter image description here

Actions: Elements: Add a variable enter image description here

Actions: Elements: Save Entity

enter image description here

Rule Export

{ "rules_summer_conference_participants" : {
"LABEL" : "Summer Conference Participants",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "webform_rules", "rules", "rules_conditional" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
  { "webform_has_id" : {
      "form_id" : [ "form-id" ],
      "selected_webform" : { "value" : { "webform-client-form-86866" : "webform-client-form-86866" } }
    }
  }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "conference_participants",
        "param_title" : "[data:last_name-value], [data:first_name-value]",
        "param_author" : [ "node:author" ]
      },
      "PROVIDE" : { "entity_created" : { "conference_participant_webform" : "Conference Participant Webform" } }
    }
  },
  { "CONDITIONAL" : [
      {
        "IF" : { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_email" } },
        "DO" : [
          { "variable_add" : {
              "USING" : { "type" : "text", "value" : "[data:email-value]" },
              "PROVIDE" : { "variable_added" : { "field_email" : "email" } }
            }
          }
        ]
      }
    ]
  },
  { "entity_save" : { "data" : [ "node" ], "immediate" : "1" } }
]  }}

Debug Info

Rules debug information:

" Reacting on event After a webform has been submitted.

  • 0 ms Reacting on event After a webform has been submitted.
  • 10.813 ms Evaluating conditions of rule Summer Conference Participants.
  • 11.057 ms The condition webform_has_id evaluated to TRUE
  • 11.067 ms AND evaluated to TRUE.
  • "Rule Summer Conference Participants fires.
    • 0 ms Rule Summer Conference Participants fires.
    • 28.914 ms Evaluating the action entity_create.
    • 29.263 ms Added the provided variable conference_participant_webform of type node
    • 31.59 ms Evaluating the action variable_add.
    • 31.649 ms Added the provided variable field_email of type text
    • 31.747 ms Evaluating the action entity_save.
    • 31.8 ms Saved node of type node.
    • 727.681 ms Rule Summer Conference Participants has fired.
  • 738.827 ms Evaluating conditions of rule Conference Participant.
  • 741.628 ms The condition webform_has_id evaluated to FALSE
  • 741.639 ms AND evaluated to FALSE.
  • 741.68 ms Saved conference_participant_webform of type node.
  • 861.009 ms Finished reacting on event After a webform has been submitted.

1 Answer 1

1

I'm not sure if these are the only issues you need to address to get the subsequent fields to populate, but I'm pretty sure these are 2 things within your Rules Actions that don't seem right to me:

  1. You don't need that "Conditional Rules"-condition, which IMO always evaluates to FALSE (and hence no variable ever gets "added", with an initial value as in your rule). To QA-test this, just (temporary) also display some "hello"-Drupal message within that CONDITIONAL, I bet you will not ever get such message (which proofs the CONDITIONAL should not be there).
  2. After you removed the CONDITIONAL (Rules Action), try to assign an initial value of [data:email-value-raw] to the variable you added, instead of the [data:email-value] in your current rule.
  3. The machine name field_email for the variable you added seems suspecious to me ... If that is ALSO the machine name of your node's field (for the node being created), then try to rework this Rules Action like so:

    • use whatever other machine name for the variable being added (let's assume you name it email_entered_on_form), with an initial value of [data:email-value-raw].
    • add another rules action to "set a data value", whereas you should set a value for field_email, and with a value equal to email_entered_on_form.

Your Answer

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

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