Hi!

I'm not sure if this is a support request or a bug report, but...

Anyway, I've set up a rule using:
Views Rules 7.x-1.0
Rules 7.x-2.3
Mimemail 7.x-1.0-alpha2

I have two content types... one is a property, the other is subscribers to a property. There is an entity reference field on the subscriber's content type linking the two. My rule sends an HTML email to all subscribers when the property's status changes.

To make this work, I've set up a View Rule (in Views) to find all the subscribers for a property, then in the Rule I loop through the View, passing variables like the subscriber's email address, and first and last name.

This is when I hit the issue with Rules 7.x-2.2 with variable tokens not working properly in direct input mode. I updated to 2.3 and could now see the new syntax for the tokens for my variables in the Replacement Patterns list. If I use them, however, I get this error:

Notice: Array to string conversion in RulesTokenEvaluator->evaluate() (line 203 of /var/www/mysite/sites/all/modules/contrib/rules/modules/system.eval.inc).

My direct input code:
Dear <span style="text-transform:capitalize;">[field-first-name:value] [field-last-name:value]</span>,

Which results in the above error and this output:

Dear Array Array,

I tried changing the tokens to [field-first-name:0:value], and got no errors, but also no output.

This DOES work, though:

<?php 
print_r('Dear <span style="text-transform:capitalize;">' . $field_first_name['0']['value'] . ' ' . $field_last_name['0']['value'] . '</span>,');
?>

I'm just thinking that either I don't know how to use the tokens properly, or they still aren't working right quite yet. I'm okay with using my workaround, but thought it might be better long term for my client if tokens could be used instead. Thoughts? Am I just not using tokens right, or is this a bug?

Thanks!

Comments

JenniferRader’s picture

Doing further tests, I've found that variable tokens for direct input mode do work IF the variable is not an array. I have a passed variable through a Views Rule loop that is a node title and the token in direct input mode works fine.

So this looks like a bug to me... or a feature request.

Example from direct input mode that worked (as help for those having this problem needing a workaround):

Investment [property-title:value] - <?php print_r($field_address['0']['thoroughfare']); ?>

czigor’s picture

Version: 7.x-2.3 » 7.x-2.7
Category: Support request » Bug report

Same here with Rules 2.7. Have you found a solution for this?

salman1225’s picture

Is there any solution or workaround to this? Without a fix to this, I can't really use Rules. Please help.

matt.rad’s picture

I am getting the same result & error messages too ("Array" instead of the expected output). In my case it is coming from Revisioning tokens.

bisonbleu’s picture

I also ran into a variant of this issue which I tracked down to views_rules.module.

This can sometimes be fixed by checking the option Rules: row variables :: Use rendered result.

TR’s picture

Status: Active » Postponed (maintainer needs more info)

Does anyone have this problem WITHOUT views_rules ? If so, please provide an export of a simple Rule which shows this behavior.

TR’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further information provided.

Alain DG’s picture

#5 worked for me... Thanks :)