Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Clone lists between sites (Client object model)

$
0
0

Hello dear colleques,

please - I am just trying to prepare some SP - COM tools for cloning lists from siteSource to SiteDest (SiteDest is Office365 encironment) I'd like to create (or modify if exists) all list on siteDest according siteSource. So, please here are my problems :

1) fields creation doesn't work on siteDest newly created list

        public static void CreateListFromOldList(Context conDestList, SP.List listTemplate)
        {
            SP.Web oWebsite = conDestList.Web;
            //create schema info
            SP.ListCreationInformation inf = new SP.ListCreationInformation();
            inf.Title = listTemplate.Title;
            inf.TemplateType = (int)listTemplate.BaseTemplate;
            //new list on dest site 
            SP.List newList = oWebsite.Lists.Add(inf);

            //fields
            foreach (SP.Field fieldSource in listTemplate.Fields)
            {
                SP.Field fnew = newList.Fields.AddFieldAsXml(fieldSource.SchemaXml, true, SP.AddFieldOptions.DefaultValue);  //new SP.Field(condestList.clientContext,newList);
            }
           newList.Update();
         
       }

New list is created OK, but only field Title are stored in list schema ....  where the bug is ?

2) is there any possibility to keep List.Id on newly created list the same, as an originla Id ?

Thank you very much, Marian


Marian


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>