cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Node using onUpdateProperties behavior is failing

dswenson
Champ in-the-making
Champ in-the-making
We have a custom status property that stores the current publishing status of an asset (Draft, published, in review, etc). When the status is set to "Expired" by our doclib action (by calling nodeService.setProperty), our onUpdateProperties behavior fires. The behavior determines that the status is now "Expired" and therefore will delete the node from the repository (nodeService.deleteNode).

Here is the issue: It appears that the setProperty function does not fully complete. Once the function is called, the behavior is triggered. Since the node is deleted in the behavior, the setProperty function cannot complete its execution (can't set property on a node that does not exist). This is confirmed by the "Node does not exist" errors that appear in our stacktrace. Since setProperty can not finish its execution, our changes are rolled back; the status is not updated and the node is not deleted. 

My question is, can this method be used to delete a node (update property on a node, have onUpdateProperties behavior delete current node)? We are using this method now since we need to automate this process as well (example: once the date is passed a documents effective publishing date, we set the status to "Expired")
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
You need to create one schedular which run after some specific time intervals and check for all nodes which are expired and then delete all those nodes. This is the best way to manage expired contents.

kaynezhang
World-Class Innovator
World-Class Innovator
No, you can not use this method to delete a node.you can use scheduled jobs or scheduled actions to implement your requirment.

mrogers
Star Contributor
Star Contributor
I'd do it in a post commit handler.    But no you can't delete the node in the middle of the update properties policy.