Rule to delete other node of same type before saving content


I have solved my problem. I found my answer in THIS HELPFUL VIDEO. In addition to what I described above, only two other components were required to be added to the "actions" section of my rule. The actions section should look like:


Fetch entity by property : Parameter: Entity type: Node, Property: Content type, Value: [node:type] Provides variables: Fetched entity (entity_fetched)

Loop : Parameter: List: [entity-fetched] List item: Current list item (list_item)

--(added to loop)--Delete entity : Parameter: Entity: [entity-fetched:0]


What I think is happening is that you're trying to delete the actual node that the user is about to save (it hasn't been saved yet)!

It doesn't look like you're finding the user's PREVIOUS node to delete first, you're just trying to work with the current one. :-)

Of course - since this current node hasn't even been saved yet (your event is prior to saving), there is nothing to be deleted.

The rule will have to be more complicated, with your finding an existing node by the current user first...

Hope this helps.

Tags: Rules

Similar questions

Change some charachter in All field before saving node
I want done a action (change some charachter) on every field in saving node. I know for specified field can use hook_node_presave ,but I want do this on all field in all content type (proximity 300 field and 40 content types) with out specify one by one . Have drupal api for hook_filed_presave or something like it? This is work for specified field
Before saving a node how to get the file path
For a content type "TEST" which has a field "upload file", I want the file path before saving the node. hook_node_presave can be used to do anything before saving the node. I want to rename the file before it get saved into database. but my file is getting saved first into the database. How to do rename a file before it gets saved into database in ...
Get text field value before saving node
I have a a custom module in which I am implementing hook_node_presave() for a content type "ABC". I want to get the value of a text field say 'field_test' before saving the node. How to do this.
Validate URL alias before saving Node
I have a custom content type which has a url alias pattern of [node:type]/[node:title]. How can I validate the node form in order to prevent the url alias from becoming [node:type]/[node:title]-0 in case the same title is used somewhere else. Basically, I would like to prevent the node from saving, and display an error message if the url alias will...
How do I update a node (book or Page) before saving it without touching the module code in Drupal?
I would like to set some values in the node before actually writing the data to the DB. I already have it working by modifying book_nodeapi but I would like to do it from outside the code, some _alter option that allows me to leave the module code untouched would be great. Thanks
Drupal: upload CCK Images before saving the node
I've defined a content-type with some text areas and a CCK Upload File (image) field. When i create a new node, if I upload the image before saving the node, it keeps uploading endlessly. If I save the node, I re-open it and I upload the image it works in few seconds. Am I forced to save the nodes before to upload images with CCK Upload Fields in D...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.