Check if nodename has changed on after publish event
Hi all,
I'm in a situation where I need to check if the node name has been changed whenever a user publishes the node. So basically I have to get the node name as it was before the publish was initiated and see if it's any different than the node name after the document has been published.
Get the curent published node name from the NodeFactory. (I think) on AfterPublish NodeFactory will still give you the old data, I think the cache doesn't get refreshed until a later event (AfterUpdateDocumentCache) - so you could compare with that.
You're a genious, Tom! Thank you so much :) It works like a charm.
So the code I ended up using was:
Node n = new Node(sender.Id);
if (!sender.Text.Equals(n.Name))
{
Log.Add(LogTypes.Custom, sender.Id, "Before published event fired and the old name was: " + n.Name);
}
Check if nodename has changed on after publish event
Hi all,
I'm in a situation where I need to check if the node name has been changed whenever a user publishes the node. So basically I have to get the node name as it was before the publish was initiated and see if it's any different than the node name after the document has been published.
Has anyone done this before? :)
Thanks in advance!
All the best,
Bo
Hi Bo,
Just a thought but it might work:
Get the current node name from the Document API
Get the curent published node name from the NodeFactory. (I think) on AfterPublish NodeFactory will still give you the old data, I think the cache doesn't get refreshed until a later event (AfterUpdateDocumentCache) - so you could compare with that.
Just a thought :)
-Tom
You're a genious, Tom! Thank you so much :) It works like a charm.
So the code I ended up using was:
For future reference.
is working on a reply...