Hello

I'm using triggered rules to send email addresses based on a cck field. Right now, I have 5 separate rules for each email address. I am trying to combine lots of rules that I have down to one.

Here is the scenario

If cck field: a
then: send email to a@mycompany.com
if cck field: b
then: send email to b@mycompany.com
...etc

However, I can't seem to find a way to move the actions to do "if" statements with the conditions. Does anyone have any insight on this?

Thank you in advance!

Comments

klausi’s picture

Component: Rules Core » Rules Engine

Have you tried to use tokens?

if cck field != ''
action: send email to [your-cck-field-token]@mycompany.com

Rules does not support an if/else workflow.

fago’s picture

Status: Active » Fixed

Please re-open if you have further questions.

nick123pig’s picture

Status: Fixed » Active

For the sake of explanation, I simplified the problem.

The actual scenario is this:

If cck field: a
then: send email to john@mycompany.com; susan@mycompany.com
if cck field: b
then: send email to nick@mycompany.com; gail@mycompany.com
...etc

Would the easiest way to implement this be to create a custom php code execution?

Thanks for your help.

nick123pig’s picture

If there is no way to do this in rules, is there a better way to have node details emailed to people? Sort of like a more advanced version of the ping module?

pyrello’s picture

@nick123pig - Are you able to upgrade to Drupal 7? If so, Rules 2 can help you out with this. If you are able to, please respond and I'll provide instructions on how you would do this.

millaraj’s picture

Hi, I would be interested in knowing how to do this if you can still provide instructions.

pyrello’s picture

@millaraj - I only know how to do it for D7/Rules 2. Is that what you are using?

millaraj’s picture

Component: Rules Engine » Rules Core

Hi, yes I am.

pyrello’s picture

@millaraj - You would do this by creating a Ruleset component. A ruleset is a set of rules that are each evaluate a condition and if the condition is met, then an action is fired.

  1. Create a component: Ruleset - www.example.com/admin/config/workflow/rules/components/add
  2. Set your variables - You are going to need a variable for the entity which has the fields you are checking. Give it a label and a machine name (it is a good idea to use something descriptive here since it can be kind of confusing later if you don't). If you are going to trigger this rule based on the the save/creation event, then your variable will be a parameter - that is, it is going to be passed into the rule.
  3. Add your first rule - give it a name like "Check if field equals 'A' and send email."
  4. Add "Entity has field" condition - In the first field, enter the machine name of your entity variable. Next select the field name from the drop down list.
  5. Add "Data comparison" condition - You will need to enter your entity:field into the data selector. Then enter the value you want to compare it to.
  6. Add "Send mail" action - You will need to enter the details of the email you wish to send.
  7. Repeat steps 3 - 6 for each additional rule you add to check a different value for the field, or a different field.
  8. Profit!

Hope that helps!

Sean

PatchRanger’s picture

There is much simpler way to do it in D7: use contributed module Rules Conditional.
It has D7 version only for now - and (as #1717620: Drupal 6 port says) is not going to create D6.
So D6 users have to find another way.

capysara’s picture

Issue summary: View changes

Thanks @pyrello! #9 is very concise and exactly what I needed!

pyrello’s picture

@capysara - No worries. Glad you could get some use out of a 4 year old thread!

TR’s picture

Status: Active » Closed (outdated)