2

I have created a content type in which I have a field as field_result of type select list with options as;

  1. pass
  2. fail
  3. hold
  4. postpone

When user selects the pass from select list and update or create a content, email should be sent to all admin users and other users stating that result is pass. Following same thing to other select list options ie for fail,hold and postpone. So what exactly I need to do using rules?

Here event can be both like; user can save the new content also can update using this select list field. Whenever user selects, it should send an email according to corresponding select list option.

Can anyone help me please? I will be thankful to you. My problem is similar to sending mail after checking a selected list in field but it didn't work for me.

  • Do you have any mail service running which can send the emails? Rule should be straight forward. I suggest try out with simplest rule you can have with out any condition as simple as When a new content is created send email to admin(avoid looping in the first go.) – arpitr Sep 10 '15 at 6:42
  • @arpitr: mail service? Smtp module i have used and i can send mail whenever i save the content this rule i created to test, but here my objective is to send email to all user when they select particular select list of field_result. – neethu Sep 10 '15 at 6:52
  • Completely understood your problem, just wanted to make sure you have a mail service in place that you have! – arpitr Sep 10 '15 at 7:08
  • @arpitr: if your familiar with rules please lend me a hand to solve this issue.Thank you – neethu Sep 10 '15 at 7:18
  • Very similar to my answer in here. Just create different rule for each option. – No Sssweat Sep 10 '15 at 7:42
1

Following rule should help you

{ "rules_send_email" : {
    "LABEL" : "Send Email After Save",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--send_email" : { "bundle" : "send_email" } },
    "DO" : [
      { "mail_to_users_of_role" : {
          "roles" : { "value" : { "3" : "3" } },
          "subject" : "Subject Test",
          "message" : "submittted value for Result field is [node:field-result]"
        }
      }
    ]
  }
}

The above rule will trigger email when a new content will be added For update also clone this rule and change the event to "After updating existing content"

  • thank you so so much, but i am new to drupal and i am not so good with rules.... and u told me to clone!!does it mean to import this code????please elaborate ur answer it will be great full. – neethu Sep 10 '15 at 7:35
  • <strong>best would be to go through rules tutorial videos drupalize.me/videos/introduction-rules?p=1157.</strong> I meant two things - Import this rule. - Once you import this, you will get option to clone it, so basically there will be two rules after that. – arpitr Sep 10 '15 at 7:39
  • :thanks for sharing ......i will watch those for better understanding. – neethu Sep 10 '15 at 9:11
  • I rarely downvote, instead I prefer to add some "constructive" critique ... (1) Are you sure you don't need a Rules Condition "Entity has field" (to ensure the field-result value IS available)? (2) no need to clone this rule (for update), just add "update" as a second Rules Event (so that the rule triggers for either event) (3) no matter which value is selected, the eMail is always the same (and includes the selected value). Why not use "conditional rules" module so that you can add a different eMail subject/msg for each value? Curious about your feedback ... – Pierre.Vriens Nov 3 '16 at 18:06
  • @Pierre.Vriens (1) Are you sure you don't need a Rules Condition "Entity has field" (to ensure the field-result value IS available)? Of course yes +1, but if you will go through the comments OP was having problem in sending mail to all users of a role(diff between send_mail and mail_to_users_of_role), but I agree the answer does not exactly solves the actual question. – arpitr Nov 10 '16 at 7:31

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.