Copyas with a Title/Name change

i’m trying to create a velocity script to simply copy an existing page to another but give the copy a different title/name. i have been able to use refactoring to create a copy but it has the same title which of course is not my intent as i just see a bunch of pages with the same ‘name’ in the bread crumb trail.

can the refactoring code below be modified to do this?

image

Hi Chris, I don’t think changing the title is supported by the rename APIs.

However you can change the title programmatically after the copy, using what’s at Scripting API Guide (XWiki.org)

Something like this:

#set ($copiedDoc = $xwiki.getDocument($destination))
#set ($discard = $copiedDoc.setTitle("new title"))
#set ($discard = $copiedDoc.save("some comment explaining the save", true))

seems to have worked perfectly! many thanks and for the quick reply.