Answers.Body: <p>You may need to add your rule here. The one by Christia is specifically about "updating a contact record in the CiviCRM" not about creating.</p>
  
  <p>The only way we have made rules work for creation from webform is to add eg a Tag to the contact and then run the trigger off that. You need civicrm_entity.</p>
  
  <p>This is cross-posted from the Drupal SE. Here is an example Rule you may be able to glean things from. It also auto logs in the contact.</p>
  
  <pre><code>{ "rules_self_create_user_account_and_login" : {
      "LABEL" : "Create User Account",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules" ],
      "ON" : { "civicrm_entity_tag_create" : [] },
      "IF" : [
        { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ] } },
        { "data_is" : {
            "data" : [ "civicrm-entity-tag:entity-table" ],
            "value" : "civicrm_contact"
          }
        },
        { "data_is" : { "data" : [ "civicrm-entity-tag:tag-id" ], "value" : "525" } }
      ],
      "DO" : [
        { "civicrm_entity_action_create_user" : {
            "USING" : {
              "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ],
              "is_active" : "1",
              "notify" : "1",
              "signin" : "1",
              "username_format" : "email"
            },
            "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
          }
        },
        { "redirect" : { "url" : "civicrm\/user?reset=1" } }
      ]
    }
  }
  </code></pre>
  
  <p>You need to Add a new Tag - note the ID of that tag - change the exported Rule to the Tag you created for this purpose. Then also alter your webform so it adds that Tag automatically to the contact upon form submission</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T09:40:38.997Z
Answers.Text: Thanks for the reply!! But I'm not getting which is the event I have to use from drupal rules. I'm not able to find  anything related to creating a new tag as a event. It woyld be really great if you can post the event, condition and action. Thanks
Answers.UserDisplayName: preeti
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T10:53:46.553Z
Answers.Text: do you have civicrm_entity installed?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T10:56:39.890Z
Answers.Text: Yes I have installed Civicrm_entity
Answers.UserDisplayName: preeti
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T16:09:28.563Z
Answers.Text: I tried to import the rule you have posted, but it fetches an error-Integrity check for the imported configuration failed. Error message: Data selector <em class="placeholder">civicrm-entity-tag:entity-id-contact</em> for parameter <em class="placeholder">civicrm_contact</em> is invalid..
Answers.UserDisplayName: preeti
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T16:39:10.373Z
Answers.Text: Thanks a lot!! it worked. But should the tag be added manually?
Answers.UserDisplayName: preeti
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T19:21:18.823Z
Answers.Text: You need to Add a new Tag - note the ID of that tag - change the exported Rule to the Tag you created for this purpose. Then also alter your webform so it adds that Tag automatically to the contact upon form submission - have also added this as an Edit.
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-29T20:25:51.290Z
Answers.LastActivityDate: 2018-05-30T19:21:40.687Z
Answers.LastEditDate: 2018-05-30T19:21:40.687Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>Here's an example Rule for Creating a user after a Webform CiviCRM submission; For the Event we're creating a helper Membership (we're really just Registering people to ride their bikes in an Event) - but the Membership gives us a nice Event to trigger on; </p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/24160/using-civimember-to-automatically-create-a-drupal-user/24163#24163">Using CiviMember to automatically create a Drupal user</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-30T14:29:32.073Z
Answers.LastActivityDate: 2018-05-30T14:29:32.073Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>I have configured the rules same as in <a href="https://civicrm.stackexchange.com/questions/16508/setting-up-rule-to-link-civicrm-contact-with-drupal-7-account.Although">Setting up rule to link CiviCRM contact with Drupal 7 account</a> it creates a drupal user if contact is created or updated in CiviCRM. But it doesn't get fired if the contact is created in CIviCRM through webform submission. It ends up with an error-"Cannot create user, email: invalid!!".Any help would be really appreciated.Thanks in advance!</p>
  
Tags: <contacts><webform-civicrm><drupal-rules>
Title: Setting up rule to link CiviCRM contact (created when webform is submitted) with Drupal 7 account
ThreadText: # Setting up rule to link CiviCRM contact (created when webform is submitted) with Drupal 7 account
  
  (Asked by: username_0 on 2018-05-29)
  
  I have configured the rules same as in [Setting up rule to link CiviCRM contact with Drupal 7 account](https://civicrm.stackexchange.com/questions/16508/setting-up-rule-to-link-civicrm-contact-with-drupal-7-account.Although) it creates a drupal user if contact is created or updated in CiviCRM. But it doesn't get fired if the contact is created in CIviCRM through webform submission. It ends up with an error-"Cannot create user, email: invalid!!".Any help would be really appreciated.Thanks in advance!
  
  **Tags:** contacts, webform-civicrm, drupal-rules
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-05-29. Score: 2 | Accepted answer
  
  You may need to add your rule here. The one by Christia is specifically about "updating a contact record in the CiviCRM" not about creating.
  The only way we have made rules work for creation from webform is to add eg a Tag to the contact and then run the trigger off that. You need civicrm_entity.
  This is cross-posted from the Drupal SE. Here is an example Rule you may be able to glean things from. It also auto logs in the contact.
  { "rules_self_create_user_account_and_login" : {
      "LABEL" : "Create User Account",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules" ],
      "ON" : { "civicrm_entity_tag_create" : [] },
      "IF" : [
        { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ] } },
        { "data_is" : {
            "data" : [ "civicrm-entity-tag:entity-table" ],
            "value" : "civicrm_contact"
          }
        },
        { "data_is" : { "data" : [ "civicrm-entity-tag:tag-id" ], "value" : "525" } }
      ],
      "DO" : [
        { "civicrm_entity_action_create_user" : {
            "USING" : {
              "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ],
              "is_active" : "1",
              "notify" : "1",
              "signin" : "1",
              "username_format" : "email"
            },
            "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
          }
        },
        { "redirect" : { "url" : "civicrm\/user?reset=1" } }
      ]
    }
  }
  
  You need to Add a new Tag - note the ID of that tag - change the exported Rule to the Tag you created for this purpose. Then also alter your webform so it adds that Tag automatically to the contact upon form submission
  
  > **Comments:**
  > **username_0**: Thanks for the reply!! But I'm not getting which is the event I have to use from drupal rules. I'm not able to find  anything related to creating a new tag as a event. It woyld be really great if you can post the event, condition and action. Thanks  
  > **username_1**: do you have civicrm_entity installed?  
  > **username_0**: Yes I have installed Civicrm_entity  
  > **username_0**: I tried to import the rule you have posted, but it fetches an error-Integrity check for the imported configuration failed. Error message: Data selector <em class="placeholder">civicrm-entity-tag:entity-id-contact</em> for parameter <em class="placeholder">civicrm_contact</em> is invalid..  
  > **username_0**: Thanks a lot!! it worked. But should the tag be added manually?  
  > **username_1**: You need to Add a new Tag - note the ID of that tag - change the exported Rule to the Tag you created for this purpose. Then also alter your webform so it adds that Tag automatically to the contact upon form submission - have also added this as an Edit.  
  
  ---
  
  ### Answer by username_2 on 2018-05-30. Score: 1
  
  Here's an example Rule for Creating a user after a Webform CiviCRM submission; For the Event we're creating a helper Membership (we're really just Registering people to ride their bikes in an Event) - but the Membership gives us a nice Event to trigger on;
  
  [Using CiviMember to automatically create a Drupal user](https://civicrm.stackexchange.com/questions/24160/using-civimember-to-automatically-create-a-drupal-user/24163#24163)
  
  
  ---
  
  