Can I clone a node, but with different node type with rules?

Events happening in the community are now at Drupal community events on www.drupal.org.
szadok's picture

I would like to create the following rule (but without success so far):
I have 2 content types: idea & discussion.
In idea content type I have added a cck field named "status" (a select list) that has: registered, approved.

Here is the rule I want to have:

If node type is idea AND field "status" is approved

Then clone the node but with as type discussion.

Any ideas how to do that?

Thanks a lot,

S.

Comments

Anyone? ideas?

szadok's picture

thoughts? rules? :-0

Thanks for the help

Tried doing something similar

itangalo's picture

I've tried doing something similar, but there is one important piece missing in my puzzle: When you create a new node with Rules, you don't get the nid back. (Saying that 'Rules doesn't give the nid back' is somewhat misleading -- it is the action that Rules uses that doesn't provide any nid result.)

I've asked a colleague to see if he can write an action, like 'Create a new node and then load it'. However, he won't have time to do this in reasonable time, so if anyone else is skilled in writing actions I'd be very happy.

IF you have such an action, what you want to do is the following:

  1. Create a rule that triggers when nodes are saved, and node type is Idea, and field status is approved.
  2. Create a new node, of type Discussion. Use title from Idea as the node title.
  3. Load the new node.
  4. Use action 'Populate field' as many times you want to fill in information in the Discussion (preferably using tokens).

I did a workaround for step 3, since I couldn't load the new node in any easy way. I included the 'old' nid in the new title, and then called a VBO that found the new node and performed a rule set on it. The rule set could then find both the new and the old node, and copy information between them.

This workaround is by all means a kludge and I don't recommend any one using it for real. I used it for a proof-of-concept, but it has many vulnerabilities and could destroy data if nodes by accident are cought by the VBO. However, if you're just interested in a proof-of-concept, it might work.

Those are my thought!
//Johan Falk, NodeOne, Sweden

Yes you can do this

nickrice's picture

I've just been playing with this as I wanted to do something similar.

The new node id becomes available as soon as you save it. So what you can do is:

  • Add new content;
  • Save a content, checking "Force immediate saving" - to save the new node. It's node id token now becomes populated.
  • etc

I didn't need the node id so just copied the couple of fields I wanted in the new node using "Populate a field", taking the value from the original node using the appropriate field token. (If you do that you don't have to do the explicit save, though I can't see offhand how to copy the body, which I wasn't bothered about doing anyway.)

The fact that the new node id token works suggests that you can also get it in php but I just wanted to do something quick and dirty so didn't play around further.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: