The doc is indeed
moved to the new location but for some reason I'm still getting the old url
even if I'm instantiating a new Node using the doc.Id from above.
//Mark document for publish
doc.Publish(sender.User);
//Publish the document by Updating umbraco.config file
umbraco.library.UpdateDocumentCache(doc.Id);
Once the cache is update you should be able to get new location url.
The general concept is first publish the document into new path after that update the cache so we can see all the changes and then refresh the content tree.
Moving Document to a new location and getting its new url
Hi there,
Im moving document to a new location using the following code:
The doc is indeed moved to the new location but for some reason I'm still getting the old url even if I'm instantiating a new Node using the doc.Id from above.
Any Idea on how to get the new url?
cheers
mkariti
Hello mkariti,
Try adding below 2lines of code after doc.Move.
Once the cache is update you should be able to get new location url.
Thanks
PTamang
Hi PTamang,
Work like a charm!
Does it have to be in a special order?
I did the following:
Also, for reference - I used the following to get the new url:
Many thanks
mkariti
Hi mkariti,
The general concept is first publish the document into new path after that update the cache so we can see all the changes and then refresh the content tree.
Thanks
PTamang
Great thanks!
is working on a reply...