Hello,
I use following rule to send email notification after content changes.

{ "rules_content_change" : {
"LABEL" : "Content update",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Content change" ],
"REQUIRES" : [ "php", "rules", "taxonomy" ],
"ON" : {
"node_update--program_course_builder" : { "bundle" : "program_course_builder" },
"node_insert--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--city_page" : { "bundle" : "city_page" },
"node_delete--city_page" : { "bundle" : "city_page" },
"node_insert--city_page" : { "bundle" : "city_page" },
"node_delete--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--page" : { "bundle" : "page" },
"node_delete--page" : { "bundle" : "page" },
"node_insert--page" : { "bundle" : "page" },
"node_update--job" : { "bundle" : "job" },
"node_insert--job" : { "bundle" : "job" },
"node_delete--job" : { "bundle" : "job" },
"node_update--news_page" : { "bundle" : "news_page" },
"node_insert--news_page" : { "bundle" : "news_page" },
"node_delete--news_page" : { "bundle" : "news_page" },
"node_insert--testimonials" : { "bundle" : "testimonials" },
"node_update--testimonials" : { "bundle" : "testimonials" },
"node_delete--testimonials" : { "bundle" : "testimonials" },
"taxonomy_term_delete--location" : { "bundle" : "location" },
"taxonomy_term_insert--location" : { "bundle" : "location" },
"taxonomy_term_update--location" : { "bundle" : "location" },
"taxonomy_term_delete--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_insert--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_update--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_delete--course_level" : { "bundle" : "course_level" },
"taxonomy_term_insert--course_level" : { "bundle" : "course_level" },
"taxonomy_term_update--course_level" : { "bundle" : "course_level" },
"taxonomy_term_delete--language" : { "bundle" : "language" },
"taxonomy_term_insert--language" : { "bundle" : "language" },
"taxonomy_term_update--language" : { "bundle" : "language" },
"taxonomy_term_delete--course_category" : { "bundle" : "course_category" },
"taxonomy_term_insert--course_category" : { "bundle" : "course_category" },
"taxonomy_term_update--course_category" : { "bundle" : "course_category" },
"taxonomy_term_delete--translation" : { "bundle" : "translation" },
"taxonomy_term_insert--translation" : { "bundle" : "translation" },
"taxonomy_term_update--translation" : { "bundle" : "translation" }
},
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "7" : "7" } },
"subject" : "content has been changed. Please change contents in your related site.",
"message" : "Following page has been changed.\r\n\r\nRevision log message:[node:log]\t \r\n\r\nChange time: [node:changed]\r\nChanged by:[node:author]\r\nNew Added: [node:is-new]\r\n\r\nType:[node-unchanged:content-type] \r\nPage Title:[node:title]\r\n\r\nGo link: [node:url]\r\n\r\nClick Revisions Tab -\u003E then click Compare button to see the differences -\u003E click \u0022Marked down\u0022 link button to view clearly\r\n\r\n\u003C?php\r\n$termid = arg(2);\r\n$term = taxonomy_term_load($termid);\r\n$title = $term-\u003Ename;\r\necho $title\r\n?\u003E\r\n ",
"from" : [ "" ]
}
}
]
}
}

All content types e.g. basic pages work well.

But for "taxonomy_term_delete--translation"
"taxonomy_term_insert--translation" :
"taxonomy_term_update--translation" :

I get the empty message, all tokens - [node:changed] [node:author] [node:is-new] :[node-unchanged:content-type] [node:title] are not being replaced with values.

How do I get the tokens to display the value? I have the following installed:
Drupal 7 version: 7.38
Rules (rules)Version: 7.x-2.9
Token (token): Version: 7.x-1.6
Entity tokens (entity_token):Version: 7.x-1.6

Comments

cam_pdx’s picture

Component: Rules Core » Rules Engine

Above when I mentioned "importing this rule", I was referring to this one from the documentation: http://drupal.org/node/298517

dwils03’s picture

I am having the same problem. In my case, I'm trying to send an email to a user. The rule executes fine, but the text of my email still has all of my tokens in it, without the replacements:

"Hi [node_author:user]!

[comment_author:user] just posted a comment on the [node:type-name] that you
posted on [node:d] [node:month].

Check it out here:

[comment:site-url]/node/[node:nid]#comments"

(I have copied the text of the tokens from my Drupal 5 site.) When using Workflow-ng and token in Drupal 5, I had a list of Replacement Items show up on the rule configuration page. I don't even see that list, even with token and token actions enabled in the modules list.

A resolution to this problem would be much apprecitated. Thanks in advance!

I'm using the following:

Drupal 6.10
Rules 6.x-1.0-beta5
Token 6.x-1.11

cam_pdx’s picture

dwils03,

I finally got this working. What I did was to try to match module for module between a fresh sandbox site and my main site (I was thinking that some module combination was the cause). After getting Rules versions matching, tokens were still breaking. Then I tried editing the affected rule and re-saving. After that, it worked. Perhaps you should try that.

Rules 6.x-1.0-beta5
Workflow 6.x-1.1
Token 6.x-1.x-dev

fago’s picture

Status: Active » Fixed

Token 6.x-1.11 -> you need a more recent version. Read the installation instructions.

Anonymous’s picture

Have the same problem here. Inserting nodeID data with PHP working as expected but no replacement when using tokens.

Drupal 6.10
Rules 6.x-1.0-beta5
Token 6.x-1.11

=======
Sorry just re-read the thread and now have it working by using the dev version of Token.

This seems to be a recurring problem. I realise that there is a note on the Rules front page that says "You need a snapshot which stems from >27.08.08" but this language isn't clear enough for the average user. It may perhaps help to spell it out and say that the release version of Token 6.x-1.11 will NOT work with Rules.

thanks

fago’s picture

ok, I added that.

gettysburger’s picture

I've been trying to get this to work for a while and was able to get system tokens like the name of the site to work, but not node-specific tokes.

I just upgraded to:
Token 6.x-1.x-dev (2009-Apr-20)
Rules 6.x-2.4

...and now if I do:

"[node:author-name] has published a [node:type-name] node called [node:title] at [node:node-url][node:nid]"...I get:

Joe Editor has published a Job node called Baking Chef at http://www.mycollegeedu/node/.

Seems now, at least, it grabs the content type and the node title, just not the path to the node. Closer, though.

ilakshmir’s picture

I am using token 6.x-1.x-dev and having a similar problem:
I have a rule that runs on a node update. On each update, I create another node labeled 'b' via the action 'add a node'. I then execute a php script to write into the fields of b. I can access [node:nid] in this php script but not [b:nid] although the token replacement patterns shows this token as available.

Any ideas for fixing this?

Thanks
iyer

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

westbywest’s picture

Status: Closed (fixed) » Needs review

Subscribing.

I was having a problem with NO tokens being processed in an email launched by a rules action.

Relevant config:
Drupal core 6.12
Token 6.x-1.12
Rules 6.x-1.0
Rules Administration UI 6.x-1.0
Token Actions disabled

Then, it worked fine after I disabled the TokenSTARTER module, even tho the configuration with TokenSTARTER enabled (but presumably unused) worked fine on an identical site.

Is there an undocumented dependency or contention between TokenSTARTER and Rules? Or perhaps a race condition?

AlexisWilke’s picture

Status: Fixed » Needs review

fago,

I ran in that problem too, with the Taxonomy Term. I found and fixed it. I will post my patch in another issue because it includes other additions (new features.)

I do not know whether this is the problem mentioned here, but what was happening in the Load Term is that the data was not at the bottom level in the array.

The array goes something like this:

  $settings = array(
    'term' => array(
       'tid' => 1,
       'name' => 'Test',
       ...
    );
  );

But the evaluations will only happen on data that are defined at the first level. Thus the 'tid' and 'name' will never be changed in these settings. I'm wondering whether the token replacement should be transformed to work on any level or just all the forms fixed to work properly.

At this time, my fix is to move form data at the time it is submitted to the top level... It works for me, but we need to know which way is correct.

Thank you.
Alexis Wilke

Update: Okay. I found the solution: #472038: Fix eval input in taxonomy actions, you add the names between pipes: term|term_text in the case of the add term. Somehow, it was fixed for the vocabulary, but I did not see the fix for the term... Anyway, you can ignore this message! 8-)

fago’s picture

Status: Needs review » Fixed

@#10: no, but when you did this your cache was cleared.
@#11: yep :)

Status: Needs review » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Drupal 6.13 (recent upgrade)
Rules 6.x-1.0
Tokens 6.x-1.12

As per #10 I made sure TokenSTARTER was off - and tried to activate and de-activate it as well.

Cleared cache (and got heaps of error messages) http://drupal.org/node/531400#comment-1859348

Turned off Trigger in Core (and therefore disabling Simplemail) just in case.

But I am not even seeing a list of tokens that can be used when I set up, or edit existing rules in question under the "Add a new rule" to a "Rule set".

I am however seeing the replacement tokens when I "Create a new rule" (singular)

The Action for both the Rule within the Set and the new Rule singular are "Send an email to an arbitrary email address" but only the Rule singular shows tokens.

[ /admin/rules is giving me white screens too upon clicking on the breadcrumb link. ]

Any ideas. Have I missed something blindingly obvious (very late night/early morning) ?

T.I.A.

Anonymous’s picture

Perhaps I am expecting a function that is not there?

I tried to create another rule set on another website and also found that 'Tokens' were not accessible to rules within sets.

Is there somewhere that this can be enabled?

jazzslider’s picture

Version: 6.x-1.0-beta5 » 6.x-1.1
Status: Closed (fixed) » Active

Hello!

I hate to re-open such an old issue, but I feel like there is a legitimate problem here; I had fixed this problem by installing the latest dev of token a few weeks back, but it resurfaced when our automatic update system accidentally restored to 1.12. On noticing this, I completely uninstalled token, reinstalled the latest dev version, and …no token replacement in emails. For reference, this is what I've got running at the moment:

Drupal 6.14
Rules 6.x-1.1
Token 6.x-1.x-dev (2009-Oct-02) [as of today…problem failed before I installed today's build, though]
Token actions disabled

Also…when I'm editing the rule, the collapsed Token Replacement Options section is definitely available. When I was running 1.11 (the first time I had to fix this problem), that part wasn't even there. So maybe this is a different issue?

I do not have tokenSTARTER enabled per #10, and I have cleared out my cache any number of times per #12. The email output from the action looks something like this:

A new node has been posted at [node:node-url] Here is a brief
summary:

[node:node-teaser]

I believe I've tried all the documented solutions…does it look like I've missed anything obvious?

Thanks!
Adam

fago’s picture

Does it work elsewhere? Perhaps there is some problem with tokens related to the e-mail action, also see http://drupal.org/node/486168.

jazzslider’s picture

Hello!

Seems to be a different problem; I read through the referenced case and tried the various solutions mentioned (adjusting action weights, deleting the action and re-creating it, etc.) to no avail. However, my symptoms are different: I'm receiving the mail (using the "send a mail to an arbitrary mail address" action), but the tokens are not being replaced.

As far as I can tell, other kinds of token replacement are working just fine on this site; e.g., our pathauto configuration uses tokens, and seems to be working.

I can't really see anything that should be causing this issue, especially since token replacement used to work correctly on this configuration. The only thing I can trace it back to is that when we automatically "updated" from the dev version of token to 1.12, it stopped working…but then when we restored back to the -dev version, it still wasn't working.

jazzslider’s picture

Hello!

Still stuck; I actually completely uninstalled both rules and token and then reinstalled the correct versions of both…re-imported my rules, and got the same result…email correctly delivered, but no token replacement.

Looking at the exported rule code, I noticed the following entry attached to the action that's sending the mail:

            '#eval input' => 
            array (
              'token_rules_input_evaluator' => 
              array (
                'message' => 
                array (
                  0 => 'node',
                ),
                'subject' => 
                array (
                  0 => 'node',
                ),
              ),
            ),

I'm not totally sure what all is going on there, but it sort of seems like it's trying to produce tokenized output…do those values look correct? If not, what should I try changing them to before re-importing my rules?

Thanks!
Adam

garretg’s picture

I had the same problem with token replacement that others report above... and I found the solution (at least for my case.)

I was missing the "Content" argument for the ruleset in which I have a "Send email" action.

Rule set arguments are a bit of a mystery to me, so I don't exactly understand what's going on.

But my guess is that the rule form codebase detects whether you have content (node) data available in the parent ruleset, and if not, it hides the token replacement suggestions link, and doesn't perform token processing when the rule is executed.

For a walk-through of how a rule set with "Content" argument should be set up, follow this tutorial:
http://drupal.org/node/517674

bombadillo’s picture

Edit of my previous post.

EDIT:

Ok i discovered the way to reproduce the bug:

if i enable a rule to trigger and send a mail when an upload field is edited
it crashes if the user decides to remove a precedently uploaded file and doesn't upload anything in replace.

It's nothing about tokens but it seems a bug.
The Drupal log says:

array_diff_assoc() [<a href='function.array-diff-assoc'>function.array-diff-assoc</a>]: Argument #1 is not an array in C:\..\mysite\sites\all\modules\cck\includes\content.rules.inc on line 338.

It's really a mistery for me.
If anyone has an advice i'm here

thanks
David

shyam541’s picture

Subscribing

brycesenz’s picture

subscribing

kbk’s picture

FWIW, I've noticed that Raw tokens are replaced while Formatted tokens fail for the same field. In my case, I was experimenting with CCK Email and CCK Text fields.

mariamr’s picture

dbassendine’s picture

subscribing

tmalo’s picture

It might be that the data_type classes are not defined when the rule is triggered.

In mymodule.rules.inc, I put those two lines :

module_load_include('inc', 'rules', 'rules.data_types');
module_load_include('inc', 'rules', 'modules/node.rules');

The replacement is now working fine.

wildguy’s picture

Component: Rules Engine » Rules Core

+1 subscribing

cwithout’s picture

I had this same problem with Rules 6.x-1.5 and Token 6.x-1.17.

Upgrading Token to 6.x-1.19 solved the problem.

wadezhu’s picture

Title: Tokens are not being replaced with a value in a Rules action » Tokens are not being replaced with a value in a Rules action for taxonomy term update
Version: 6.x-1.1 » 7.x-2.0
Issue summary: View changes
Issue tags: +rules
Related issues: +#432518: Tokens are not being replaced with a value in a Rules action for taxonomy term update

I use following rule to send email notification after content changes.

{ "rules_content_change" : {
"LABEL" : "Content update",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Content change" ],
"REQUIRES" : [ "php", "rules", "taxonomy" ],
"ON" : {
"node_update--program_course_builder" : { "bundle" : "program_course_builder" },
"node_insert--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--city_page" : { "bundle" : "city_page" },
"node_delete--city_page" : { "bundle" : "city_page" },
"node_insert--city_page" : { "bundle" : "city_page" },
"node_delete--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--page" : { "bundle" : "page" },
"node_delete--page" : { "bundle" : "page" },
"node_insert--page" : { "bundle" : "page" },
"node_update--job" : { "bundle" : "job" },
"node_insert--job" : { "bundle" : "job" },
"node_delete--job" : { "bundle" : "job" },
"node_update--news_page" : { "bundle" : "news_page" },
"node_insert--news_page" : { "bundle" : "news_page" },
"node_delete--news_page" : { "bundle" : "news_page" },
"node_insert--testimonials" : { "bundle" : "testimonials" },
"node_update--testimonials" : { "bundle" : "testimonials" },
"node_delete--testimonials" : { "bundle" : "testimonials" },
"taxonomy_term_delete--location" : { "bundle" : "location" },
"taxonomy_term_insert--location" : { "bundle" : "location" },
"taxonomy_term_update--location" : { "bundle" : "location" },
"taxonomy_term_delete--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_insert--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_update--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_delete--course_level" : { "bundle" : "course_level" },
"taxonomy_term_insert--course_level" : { "bundle" : "course_level" },
"taxonomy_term_update--course_level" : { "bundle" : "course_level" },
"taxonomy_term_delete--language" : { "bundle" : "language" },
"taxonomy_term_insert--language" : { "bundle" : "language" },
"taxonomy_term_update--language" : { "bundle" : "language" },
"taxonomy_term_delete--course_category" : { "bundle" : "course_category" },
"taxonomy_term_insert--course_category" : { "bundle" : "course_category" },
"taxonomy_term_update--course_category" : { "bundle" : "course_category" },
"taxonomy_term_delete--translation" : { "bundle" : "translation" },
"taxonomy_term_insert--translation" : { "bundle" : "translation" },
"taxonomy_term_update--translation" : { "bundle" : "translation" }
},
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "7" : "7" } },
"subject" : "content has been changed. Please change contents in your related site.",
"message" : "Following page has been changed.\r\n\r\nRevision log message:[node:log]\t \r\n\r\nChange time: [node:changed]\r\nChanged by:[node:author]\r\nNew Added: [node:is-new]\r\n\r\nType:[node-unchanged:content-type] \r\nPage Title:[node:title]\r\n\r\nGo link: [node:url]\r\n\r\nClick Revisions Tab -\u003E then click Compare button to see the differences -\u003E click \u0022Marked down\u0022 link button to view clearly\r\n\r\n\u003C?php\r\n$termid = arg(2);\r\n$term = taxonomy_term_load($termid);\r\n$title = $term-\u003Ename;\r\necho $title\r\n?\u003E\r\n ",
"from" : [ "" ]
}
}
]
}
}

All content types e.g. basic pages work well.

But for "taxonomy_term_delete--translation"
"taxonomy_term_insert--translation" :
"taxonomy_term_update--translation" :

I get the empty message, all tokens - [node:changed] [node:author] [node:is-new] :[node-unchanged:content-type] [node:title] are not being replaced with values.

How do I get the tokens to display the value? I have the following installed:
Drupal 7 version: 7.38
Rules (rules)Version: 7.x-2.9
Token (token): Version: 7.x-1.6
Entity tokens (entity_token):Version: 7.x-1.6

Thanks,

tr’s picture

Status: Active » Closed (outdated)
Issue tags: -rules

If you continue to have a problem with this in the current version of Rules please open a new issue.