14

Is it possible to use the core service to copy items from one publication to another?

I have a scenario where I need to copy SGs and pages to a new publication, and whilst doing this loop through each page in the SG, checking every component on each page and copy them to a different parent publication IF the content hasn't already been created there.

So basically:

  • Loop through SG's (keep a note of SG metadata)
  • Check for pages in SG (keep a note of page metadata and component presentations)
  • Check through each component in found pages
  • If any of the components haven't been created at PublicationA, create a copy of them to PublicationA
  • After doing this, create a copy of all the SG's and Pages found and dump them into a new publication (PublicationB) keeping all the mappings with the SG metadata (if exists), and pages (with page metadata if exists and component presentations)

I'm currently looking through the documentation but if anybody could tell me if something like this is possible it would really help me out.

EDIT

One thing I've forgot to ask here is if it's possible to add component presentations to pages after creating them via the core service? We know from Bart and Nuno's replies that pages can be created but can CPs also be "re-added" whilst looking at an existing page?

15

Yes and no, you will not be able to copy the item directly to a different Publication using the Copy or Move methods (at least I would expect that to fail, as the CMS doesn't support cross Publication copy/move actions).

But you can use the Core Service to create a new item and populate that with the content of your original item. This will mean you get a new TCM URI for that item, so you will have to edit all the items it is used in and replace the links to your new item, before you can delete the old one.

  • Thanks Bart. So does this apply for any item type? For e.g. Can I create a new SG/Page in PublicationB and populate it with the contents of an existing SG/Page in PublicationA? – Ibrar Hussain Apr 9 '13 at 18:53
  • 3
    As long as you can fulfill all of the dependencies of the page, sure, why not? – Nuno Linhares Apr 9 '13 at 18:56
  • Well, let's take a page for example, we'll have page metadata to handle and CPs. CPs will include both components and CTs. So is it possible to retain all this information when creating a new page at a different location? – Ibrar Hussain Apr 9 '13 at 19:03
  • Furthermore, whilst looping through each page whilst retaining each CP, I need to check if each component against every CP has been created at the correct publication, if not I will want to re-create this. – Ibrar Hussain Apr 9 '13 at 19:06
  • a lot of functionality you have to build, but nothing that can't be done with the Core Service, you just need to follow the API guide and all examples out there (there have been quite a lot of questions about it here and on StackOverflow already) – Bart Koopman Apr 10 '13 at 7:02
9

Depending on your scenario, it might be useful to consider temporary modifications to the blueprint. Assuming your new publication is to be in the same master chain as the source publication, could you add the source publication as a parent long enough to do a copy/paste within the new publication, and then restore the blueprinting relationships to the way you want them. As I say - this depends a lot on your scenario, as a lot of blueprinting activities come with constraints.

3

I just wanted to add comment to this ticket that we had simmilar situation where client wanted to copy entire publication. We did so by creating tool using core service where we copied entire publication to other one.

We copied:

  • pages and cps on it
  • components
  • categories/keywords
  • folders and structure groups
  • bundles

We tested and everything works fine.

We used this ticket as reference so thanks for sharing it.

  • 1
    Glad you got it working! :) – Ibrar Hussain Mar 1 '17 at 8:31
3

Please WebDAV moving and copy items

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.