-1

In my content i have an select list text field.I have an four options far that,while clicking only particular one in select list and giving click save.Then i want to generate mail to administrator. example:i have select list field like born,dead,live,none...while user selecting born and going to click save.I want to send a mail for administrator,how can i create it by using rules.

0

I tried to recreate your situation. In my case I have a field Category which is a term reference of the Vocabulary Category which have the terms tid pair as:

Category 1 => 1
Category 2 => 2
Category 3 => 3

Now my rule will be triggered when a node of type article is created or edited with the field_category as 2 then it will send a mail.

This is the export of the Rule that I created.

{ "rules_send_mail_when_category_is_2" : {
    "LABEL" : "Send mail when Category is 2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : {
      "node_insert--article" : { "bundle" : "article" },
      "node_update--article" : { "bundle" : "article" }
    },
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "article" : "article" } } } },
      { "data_is" : { "data" : [ "node:field-category:tid" ], "value" : "2" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : "[node:author]",
          "subject" : "[node:title]-[node:field-category] Selected",
          "message" : "This is a system generated mail",
          "language" : [ "" ]
        }
      }
    ]
  }
}
  • @Tewari -i am doing by custom metheod.i dont have that much of knowledge in code.where should i implement this code -thank you for answering me – DINE Sep 7 '15 at 12:08
  • function MYMODULE_default_rules_configuration() { $items['my_rule'] = entity_import('rules_config', 'EXPORT STRING HERE'); return $items; } This should work. – Malabya Tewari Sep 7 '15 at 12:22
  • @Tewari: I am not getting where to keep this code and how to use this code in order to achieve this requirement, and sorry to ask this!!!! – DINE Sep 7 '15 at 12:36
  • You can put this in any of your custom module. – Malabya Tewari Sep 8 '15 at 5:16
  • @Tewari-Thanks for your response yah i understood how to import code,my rule name=new litter,content name=cage-card-info ,label name=Warnings,machine name=field-warnings ,can you modify in the above code!!feel great. – DINE Sep 8 '15 at 7:07

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.