Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
As based on the token description, Body [message:field-node-ref:body:?] The main body text of the node. The following properties may be appended to the token: value (Text), summary (Summary), format (Text format)
However, when I tried [message:field-node-ref:body:value] , [message:field-node-ref:body:summary] , [message:field-node-ref:body:format] , all of them are NOT rendered with value.
Comments
Comment #1
sadashiv CreditAttribution: sadashiv commentedHi,
I was facing the same issue. One more interesting issue is that if I use [message:field-node-ref:body] then it's not replaced in the email but when I see the message on the site i.e. at /admin/content/message then it shows the message as it should be.
I tried to debug and found that the problem exists in entity_token.tokens.inc
hook_tokens in the file has a code
The $value returns a complete object when we try to update the node so the token is replaced and we get the complete message and when we create a new node it has all fields empty so the token is not replaced.
I think this may be because the fields are not written to the db or a cached copy of the entity gets served thus it don't have any field data thus failing the token.
I checked node_save and found that it creates the fields and then invokes node_insert so my hook is triggered after the fields are saved so I tried clearing entity_cache before calling message_subscribe_send_message
Use this code before calling the message_subscribe_send_message or message_notify_send_message function
Here $node is the newly inserted node on which we want to trigger message.
May be this can be included in some documentation so that we reset cache if we want to use the token for new node or can be included in the message_notify
Hth,
Sadashiv.
Comment #2
ndobromirov CreditAttribution: ndobromirov at FFW commentedI made it work with just [message:field-node-ref:body] so it might be the description that is broken / incorrect.
Comment #3
bluegeek9 CreditAttribution: bluegeek9 as a volunteer commented