SharePoint list items with search fields - move / copy to another site collection

Here is the script. Our user archives of SharePoint jobs (based on ceratin crteria) and copy / move items to another site collection. In this case, if the list item has some search fields, how to save them when copying / mpve to another site collection?

Thank you Durga

+3
source share
2 answers

The internal name of the search field must remain unchanged, and as long as the list referenced by the search field uses the same values ​​(the identifier may be different, just match the value and create a new SPFIeldLookupValue), there is no problem copying metadata based on the internal field names and everything should go well, we do the same for archiving news and documents using timerjobs.

0
source

you cannot "copy" a field from sitecoll A to sitecoll B, you need to recreate it. The usual way to do this is to actually use a function that creates the search field, but this is not the case that I assume (should have been done at the beginning, in the future I suggest how you create the fields, seeing how this method is reused).

, SPSite- b sitecoll , field.SchemaXml, , sitecoll b. AddFieldAsXml SPSite.Fields, , InternalName .

,

CHeck, :

 using(SPSite targetSite = new SPSite("urloftargetsite"))
 {
   using(SPWeb targetWeb = sourceSite.OpenWeb())
   {
     if(!targetWeb.Fields.ContainsField(originalField.InternalName))
     {
        targetWeb.Fields.AddFieldAsXml("caml string here");
     }
   }
 }
0

Source: https://habr.com/ru/post/1721217/


All Articles