Clone Your Content in UCM
By Kyle Hatlestad on Nov 16, 2009
As part of the Blogs and Wikis sample sites available from Metalink, they include supporting components to make them functional. One of the interesting ones comes with the SampleWiki component.
When you load the SampleWikis component, it will also install a component called 'NewItem'. The purpose of this component is to copy/clone existing content items. The wiki site makes use of this by automatically making a copy of a "starter" data file each time you establish a new wiki page. This way the user doesn't have to go through the process of checking in that new data file themselves.
But that functionality may come in handy for you outside the context of a wiki site. Let's say you have a set of standard Word documents that you use as templates. Or maybe a generic corporate sales slide deck. They are a starting point for new documents to be created from. You can use this cloning service to automatically create those new unique documents.
All you need to do is call the CHECKIN_NEW_ITEM_BY_NAME service and pass it the Content ID (dDocName) of the original item. Here is an example of what the URL would look like:
This will create an exact copy of the content item with both the file and metadata. The only thing that will be different is the Content ID. The only other consideration is for items in contribution folders. Because no two files can be in the same folder with the same native file name, the file name of the cloned item will have a unique identifier applied to the name.
Not only can you call it directly in the URL, it's also scriptable so that you can call it within idoc script or through our APIs. And in addition to simply passing the dDocName, you can also pass other metadata fields if you want to override the values of the original. So if you want your cloned item to have a Title that is different, simply pass it a new value for dDocTitle.
In the 7.x version of Content Server, this component added a menu choice on the Content Information page that let you clone the item right there. Because the menu code changed in 10gR3, you no longer see that choice (and why most folks are unaware it's there). But you can easily add the code into the component to get that working again. You can either modify the NewItem component in Component Wizard or modify the resource file directly. The file to modify is [ucm dir]/custom/NewItem/resources/newitem_resource.htm. You then want to add the following section above the closing body tag:
<$PageMenusData.nodeId = "NEW_ITEM"$>
<$PageMenusData.parentId = "CONTENT_ACTIONS"$>
<$PageMenusData.label = "wwCheckInNewItem"$>
<$PageMenusData.type = "item"$>
<$PageMenusData.href="HttpCgiPath" & "?IdcService=CHECKIN_NEW_ITEM_BY_NAME&dDocName=" & dDocName$>
<$PageMenusData.loadOrder = 100$>
In the previous menu code, it references the CHECKIN_NEW_ITEM service, but that service is not configured correctly in the component so the CHECKIN_NEW_ITEM_BY_NAME service is preferred. After modifying the component, restart Content Server.
You should now have a 'Check In New Item' choice on the Content Actions menu on the Content Information pages. You can change the PageMenusData.label line above if you want to provide a different menu label.
Please refer to the readme.txt included with the component for more details and additional example code.