Strange issue here.

I have a flag which creates new content type "collaboration" when flagged. I am trying to redirect the user to the new content after it is created. Redirect, uses the following url with token replacement.

node/[collaboration_added:nid]

if I print out a configured message, [collaboration_added:nid] is NULL. Interestingly, a configured message with [collaboration_added:title] works just fine.

0 ms "A node has been flagged, under "Schedule Collaboration"" has been invoked.
7.175 ms Executing the rule "Create Collaboration" on rule set "A node has been flagged, under "Schedule Collaboration""
20.429 ms Action execution: "Add new collaboration"
24.381 ms Successfully added the new variable "new content of type collaboration"
40.761 ms Action execution: "Show a configurable message on the site"
47.078 ms Action execution: "Page redirect"
47.232 ms Saved variable new content of type collaboration of type node.

I don't know a whole about this but it appears it's trying to redirect me to a node that hasn't been saved yet. Can't understand why token for title works, but not the nid????

Comments

amitaibu’s picture

Component: Rules Core » Rules Engine
Category: bug » support
Status: Active » Fixed

Your event should be triggered "After saved content" and not "content is going to be saved", since there's no node ID yet in the DB.

tpainton’s picture

actually. I am triggering the creation of content when a node is flagged. I think I see your point though.. I need another event to go off when this content I created (from flagging) AFTER it is saved.. This just add a conditional statement to make sure it's the correct content type. Thanks.

Status: Fixed » Closed (fixed)

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

rc2020’s picture

I can also confirm this problem. If I create a new node from the flag, the node doesen't have access to node id token or $node->nid.

rc2020’s picture

Status: Closed (fixed) » Active
langworthy’s picture

I ran into this same problem.

#1 says to use the trigger "After saved content". In Rules 1.3 this is not an available trigger. However, "After saving new content" is available.

I've had to duplicate two Rules using the triggers "After saving new content" and "After updating existing content". It would be helpful if there was a trigger "After saving content".

TR’s picture

Component: Rules Engine » Rules Core
Issue summary: View changes
Status: Active » Closed (outdated)