We are developing a new portal using Kentico v12.0.51 MVC and we need to automatically update the value of a certain field each time a node is updated, inserted or moved. The value of this field is computed by concatenating the values of the same field of the node’s ancestors. Please note that this field is not visible to the user.
In order to maintain the value of the field, we have created a custom module in the Kentico admin solution. In the custom module we have created an event handler for the following document events:
Each time one of the above events is triggered for a given node, then a twostep process is executed.
During the first step, we update the value of the field for the current node (the node passed by the event handler) according to the corresponding values of its ancestors and then we save the node using the node.Update() method.
During the second step (and while a certain condition is met) we load all the node’s descendants and apply a similar update process.
The problem we are facing is occurring during the second step. Each time we call the node.Update() function then the DocumentEvents.Update.After event is triggered, leading to recursive execution.
What we need is a way to suppress the event recursion during the two steps process for a given node.
We already have tried the DocumentEvents.Update.ControlRecursion = true but the recursion is still occurring.
If such a feature is provided by Kentico, please advise accordingly.
If not, is there any other way to explicitly trigger the recursion without executing the node.Update() method? If such an option is provided, then we may proceed to refactor the code in order to trigger the event only for the node’s immediate children (not all descendants) without saving them and taking advantage of the recursion we will still be able to span the update operation to the entire node’s sub tree.
Thanks in advance,