0

I want to copy a list (as it is with the same properties/metadata) from Sharepoint Online to another list in another tenant.

I want to also copy all the properties and metadata of each item.

I'm using C# and CSOM

1

The easiest is to save the list as a template with content and download the file, re-upload it as a template in the new destination

  • 1
    Can you please attach some details about how to sava list as a template and then upload it? – Robert Lindgren May 6 '15 at 9:03
  • can i have code plz , and in case of library , i should save all file in my pc !!! is thre another solution? – Khaw'la Karray May 6 '15 at 9:42
  • this procedure is done via the interface – susan May 6 '15 at 9:44
  • i want to do it via my application (windows form , c#) – Khaw'la Karray May 6 '15 at 11:11
0

you may use SharePoint API and C# to do this and you may refer to the below link as a reference

Part 1: Copy a SharePoint List Programmatically

Here's the code:

// Instantiate web instances
SPSite sourceSite = new SPSite(@"http://SharePointServer:31001");
SPWeb sourceWeb = sourceSite.RootWeb;
SPSite destSite = new SPSite(@"http://SharePointServer:31002");
SPWeb destWeb = destSite.RootWeb;

// Get a reference to the source list
SPList sourceList = sourceWeb.GetList("/Lists/Announcements");

// if the list exists on the destination site, delete it
try
{
   SPList temp = destWeb.Lists[sourceList.Title];
   destWeb.Lists.Delete(temp.ID);
}
catch { }

// create new list on the destination web with same properties
Guid newListID = destWeb.Lists.Add(sourceList.Title, sourceList.Description,
                                   sourceList.BaseTemplate);
SPList destList = destWeb.Lists[newListID];

// copy items
foreach (SPListItem item in announcements.Items)
{
   SPListItem newDestItem = destList.Items.Add();
   foreach (SPField field in sourceList.Fields)
   {
      if (!field.ReadOnlyField)
      newDestItem[field.Id] = item[field.Id];
   }
   newDestItem.Update();
}

// set quicklaunch settings
destList.OnQuickLaunch = sourceList.OnQuickLaunch;
destList.Update();

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.