Hello,
I have not found any answer to the following issue.
I am using Rules to send emails "after updating an existing content".
For any field of the "Send mail" action, if I am using the "Data Selection" mode, the token that I choose comes out fine in the email sent ([node:title] is replaced by the title of the node).
However, I need to add some extra text to my Message body, so I switch to "Direct input" mode. And here:
- no token shows under replacement patterns section.
- when I put any token such as [node:title] or [node:field-date:value], it returns a blank space in the email instead of the value it stands for.
Another issue which seems related, the PHP evaluation option does not show either when either on "Direct input" or "Data Selection" mode.
Config:
Rules, Rules UI (All 7.x-2.9)
Workflow Rules 7.x-2.5
Entity tokens, Token 7.x-1.5
Token tweaks 7.x-1.x-dev
HTML Mail 7.x-2.65
Mail System 7.x-2.34
Comment | File | Size | Author |
---|---|---|---|
#19 | 1533398-19.patch | 1.39 KB | rlmumford |
#10 | rules-tokens-1533398-10.patch | 1.25 KB | larowlan |
Comments
Comment #1
Back From 7 CreditAttribution: Back From 7 commentedCONFIRMED: 'send an email' action with the following modules.
Entity 7.x-1.x-dev
Rules 7.x-2.x-dev
Token 7.x-1.x-dev
[node:url] token replacement works and shows up in email.
Comment #2
Back From 7 CreditAttribution: Back From 7 commented'Send mail to all users of a role' DOES NOT WORK. Used the same configuration as 'send email' THIS IS A MAJOR PROBLEM...
Comment #3
Back From 7 CreditAttribution: Back From 7 commentedSOLUTION: It seems like Mime Mail module did the trick. It allows for html mail system. Maintainers need to mention this in "required modules". I would think email rules are widely used...
Comment #4
marty.true CreditAttribution: marty.true commentedI have Mime Mail installed and it still will not send emails when using a token in the body of the message. I am not using "Send as HTML". Confirmed, when removing the token, the emails go through...
Comment #5
greenitcompany CreditAttribution: greenitcompany commentedI'm also experiencing this issue. Has anyone identified a solution?
Comment #6
ezeedub CreditAttribution: ezeedub commentedSeems to me this problem is about token replacement and not email, if the email works without tokens.
I encountered the error last night, but today haven't been able to re-create it. :/
Anyway, for me it was related to not being able to get at [entity:nid], without first loading it. So, in my actions, I first "fetch entity by id" using entity:nid as a data selector, and then when I want the token, I use [entity-fetched:nid].
I don't understand why this works though.
Comment #7
Back From 7 CreditAttribution: Back From 7 commented@xstatic
Make sure to configure Mimemail to be used system wide. There is a configuration under Mimemail settings I think. You have to tell Drupal to use Mimemail html mail site wide.
Hope this helps!
Comment #8
nlisgo CreditAttribution: nlisgo commentedI am getting the same error if I set up an action to 'Show a message on the site' and use the data selector and refer to any of the variables like site:mail for instance. It will save but when I return to edit the action that message is displayed.
Comment #9
raphpaelle CreditAttribution: raphpaelle commentedHi,
I've got the same problem, token replacement doesn't work when using token such as node:author or node:author:mail. It's really blocking.
Is there any way to solve this problem please?
Comment #10
larowlanThis works for me.
Seems to be when the data type 'entity' is involved. For which there are no tokens.
This tests for that and drops back to the raw entity and entity_type.
Comment #11
thememex CreditAttribution: thememex commented@larowlan
Thank you for posting this patch. I've been banging my head against a wall for weeks trying to get a Rule to set a text field value to a Token. That Token is an 'entity' type containing arrays. Example: [entity:field-date-repeat:0:duration]
I had built the rule to look for entities with entity:field-date-repeat, and even set a condition to check if the entity:field-date-repeat:0:duration had a value. All the rule would ever do is populate the field and set a blank value. I could add text or PHP or site tokens (ie - [site:name]) and all of those would populate my text field. I just could not pull in the array value from an entity token.
Simply applying your patch to Rules (I'm on version 7.x-2.9) instantly fixed this problem for me with no changes to my existing rule.
Thank you. Thank you. Thank you.
Comment #12
eawheeler CreditAttribution: eawheeler commentedI can confirm that the patch per # 10 solved my problem. My rule sends an email message on node update. Prior to patch application, the message body field would not populate [entity:url] tokens and rule triggering would result in the following UI error.
Undefined index: entity_type in uuid_tokens() (line 51 of /var/www/html/profiles/panopoly/modules/contrib/uuid/uuid.tokens.inc).
I had attempted another approach that fetched entity by id. That worked up to a point and resolved the token population issue. However it also resulted in PDOExceptions.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
The PDO error possibly occurred because I had applied more than one rule to the content type that retrieved IDs in this fashion. In any case, after patch application I was able to rework the rule to use [entity:*] tokens and removed the "fetch entity by id" actions.
Comment #13
eawheeler CreditAttribution: eawheeler commentedComment #14
Göran CreditAttribution: Göran commentedTHANK YOU!
This Patch solved a major problem ho did come up, after the core (dp7.38 from 7.37) and some module was updated. I hade a Rule who find value from fields inside a book-ancestor-2:
After this patch update - Rules is able to find the values and the missing fields value.
Thanks a lot for this patch i it rescued my day, or probably the hole week...!
Comment #15
Göran CreditAttribution: Göran commentedComment #16
crutch CreditAttribution: crutch commentedVery odd. Tokens were not working in email message field, plain text. Applied patch #10. Tokens started working. Reverted to original system.eval.inc file, tokens are still working.
Comment #17
rlmumfordPatch is still good on latest dev. Can this get committed?
Comment #18
museumboy CreditAttribution: museumboy commentedI'm having a similar problem, but I can't get anything to work even after I applied the patch. Here's the code in my email rule:
If info-request-1 is checked I get an email saying: string true the value of the var is true.
if info-request-1 i NOT checked I get an email saying: string false the value of the var is false.
Additionally, when the rule is run I see the same "warning: Undefined index: entity_type in uuid_tokens()” others have mentioned.
Why isn't my logic working?
Comment #19
rlmumfordThe patch in #10 breaks tokens in entities where the entity type differs from the token type (Commerce Order being one example). This updated patch solves the bug while maintaining the existing functionality.
To test import the following rules component and execute:
With Patch: The user name token will be correctly replaced
Without Patch: The user name token will be replaced blank.
Comment #20
nvahalik CreditAttribution: nvahalik at Code and Salt commented+1 to the patch in #19.
Comment #21
TR CreditAttribution: TR commentedComment #22
TR CreditAttribution: TR commentedIt seems to me that this is the same as the problem being discussed in #2420687: Add token support for "any entity" data type.
I like the patch in that issue better.
Can someone look at both issues, figure out what needs to be fixed, and consolidate the two?
Comment #23
TR CreditAttribution: TR commentedSee #2420687: Add token support for "any entity" data type