Copy list items from one sharepoint server to another programmatically - sharepoint

Is it possible to copy a sharepoint list from one server to another server?
So I have server A running site 1, I want to copy the list from ServerA-Site1 to ServerB-Site1.
I've seen numerous articles on SO, to copy from one site to another as long as the sites are on the same server.
I've already looked at several articles like: Programmatically copying custom content type and columns from one web to another
copy list items from one list to another in sharepoint
From the looks of things, it does not seem possible but I'd like confirmation or direction to a possible answer (if I wasn't looking in the right areas)

You can try to use Client Object Model
But it can be tricky because of some special field types (for example, metadata field or person or group field).

Yes, it is possible. You can define two client context for each of your site and then get the required lists and update them using some variables. This should do it for you.

See the content migration API:
http://msdn.microsoft.com/en-us/library/ms453426.ASPX
You should be able to export items, transport them to the second server, then import them.

Related

KQL (Keyword not Kusto) Nesting, Document Selecting for an Extranet

Longtime member, been a while since posting. Working on building out an Extranet and am running into a stupidly frustrating issue. First time using SharePoint Online as document repository for external (anonymous) users. In doing so, using Azure permissoning, have the documents split up in repositories on SharePoint based on access level. On top of that I am attempting to display them in Highlighted Content Web part, I am not able to sort them out by location AND type. I have a custom column in each repository that defines what type they are, but when I try to add the AND portion to the KQL it doesn't work. Additionally the internet seems to be massively void of actual documentation of KQL.
(
path:https://domain.sharepoint.com/sites/example/Level%201%20Resources/
OR
path:https://domain.sharepoint.com/sites/example/Level%202%20Resources/
OR
path:https://domain.sharepoint.com/sites/example/Level%203%20Resources/
OR
path:https://domain.sharepoint.com/sites/example/Level%204%20Resources/
OR
path:https://domain.sharepoint.com/sites/example/Level%205%20Resources/
OR
path:https://domain.sharepoint.com/sites/example/Level%206%20Resources/
AND
DocType:"Articles"
)
The above will simply pull all documents from those locations and ignore the AND statement. I have tried renaming it to call on the custom column identifier pulled from the source, and that doesn't work either.
The only real documentation I can find on this is: Here
Which doesn't appear to address filtering based on custom column tags.
EDIT: Reformatted to pull all docs from multiple locations using below, but the nesting portion still isn't working
path:(
"https://domain.sharepoint.com/sites/example/Level%201%20Resources/"
OR
"https://domain.sharepoint.com/sites/example/Level%202%20Resources/"
OR
"https://domain.sharepoint.com/sites/example/Level%203%20Resources/"
OR
"https://domain.sharepoint.com/sites/example/Level%204%20Resources/"
OR
"https://domain.sharepoint.com/sites/example/Level%205%20Resources/"
OR
"https://domain.sharepoint.com/sites/example/Level%206%20Resources/"
)
So the additional issue I was running into was the creation of a column to separate out based on the category of file type (not literal file type). Apparently SPO doesn't like it when you create a list and then reference that list to then filter by via KQL. So I found this morning this.
Apparently the best way to do this is create a custom "Choice" column, allow some time for it to flow and update, and then you can reference it via KQL.

Link to another item in a sharepoint document library

I am writing a custom Sharepoint solution and I have to fulfill a requirement that an item in 1 document library must be visiable in another document library, e.g. maintaining global company document which should display in all other librarys
I need to sync properties, e.g. name so that when it changes in the source list it should also change in the destination lists. The items created in the destination list should not be able to have workflows or other options in the ECB Menu (exception for maybe going to source document).
Does anyone have a realistic solution on how to accomplish this ?
I have been trying to use CopyIntoItems of the copy web service to create linked copies with no luck, it always just creates a new copy of the source item (see: http://platinumdogs.wordpress.com/2009/01/14/sharepoint-moss-creating-document-library-items-uploading-files-to-a-document-library/)
Creating a custom content type has also entered my mind (since the source properties is contained in a content type) but then how do I filter the ECB menu ?
If the destination document library is a replica of the source document library, can't you solve this by displaying the items on the destination side using a content query web part instead of duplicating the items?
In the process for googling for something else I might have come across the solution to your problem.
Apparently Sharepoint has a built in 'linked document' type. You can just use that to link the documents, instead of copying.
More info here.

Combining different lists data and showing it in a webpart

let me explain my current situation
i have a SharePoint site lets say it is MAIN, and a subsite lets call it SUBMAIN
in MAIN i have a list called "a" and in subMAIN i have a list called "b"
both lists have the exact same columns,
i need to show the content of both lists (ordered by modified date for example) in one webpart in the main page i know it is possible some how but couldnt get to it.
currently i am showing only the content of list "a" in a content query webpart (i have changed the way it display and added to it horizontal merquee) so it will be nice if somehow i can add contents of list"b" also to the same content query webpart (but if it is not possible in content query webpart its ok, at least let me know what other options do i have)
your help is appreciated
If you are using SharePoint Designer to do this, take a look at this blog.
If you are building your own web part, I would perform two queries on the SPList objects. You can then aggregate, sort, etc. the results however you would like. If you aren't familiar with SPList, you can look here for the MSDN overview.
I've built web parts to display items from 2 different lists, and I did something similar to what Scott Price suggested. I used an SPQuery object for each list and used it to get DataTable objects that I could then use with things like Repeaters and DataLists. You could merge your two tables and do something similar.
The biggest trick for me was setting up the custom templates for DataBinding in a webpart. To do that, I created a custom class that implemented the ITemplate interface and then emitted the HTML for each item from the template class in an event handler. Then, you just create an instance of your template class and set that as the ItemTemplate property of your, say, DataList.
This post and this one do a better job of explaining that approach, but the nice thing is that you have complete control of the markup, and you can style it as you like.
If you're not looking to code your own solution, you might consider this webpart on codeplex:
http://rssaggregator.codeplex.com/
It's actually an RSS aggregator, but since all SharePoint lists have built-in RSS feeds, you can use it just as well to aggregate the SharePoint lists from the different sites.
Another approach is SLAM, SharePoint List Association Manager, an open source project my company created and actively supports. SLAM will allow you to configure those two lists to be automatically synchronized to SQL tables at which point you can create a query to join the two. If you have the two lists built off a content type (since they have the same fields) you can actually slam the content type and have both lists in the same SQL table.

Representing parent-child relationships in SharePoint lists

I need to create some functionality in our SharePoint app that populates a list or lists with some simple hierarchical data. Each parent record will represent a "submission" and each child record will be a "submission item." There's a 1-to-n relationship between submissions and submission items. Is this practical to do in SharePoint? The only types of list relationships I've done so far are lookup columns, but this seems a bit different. Also, once such a list relationship is established, then what's the best way to create views on this kind of data. I'm almost convinced that it'd be easier just to write this stuff to an external database, but I'd like to give SharePoint a shot in order to take advantage of the automated search capabilities.
Proper Parent/Child in Sharepoint is near impossible without developing it yourself. There is one approach to that here: Simulate Parent / Child relationship in SharePoint 2007 with Folders & Content Types
(Note: This concerns SharePoint 2007. In 2010, Joins make this much easier)
Do it in a separate database, create a page(s) with controls that surfaces the data and run search over that. Loses quite a bit of the SharePoint features though.
Otherwise it may be okay to create a custom field control that will allow you to lookup the data in the other list.
The custom field control can be the one to "view" the related data.
I know we have done it for parent child relationships between pages on the same list. Not 1-to-N though.
Tough choice either way.
My vote is "to write this stuff to an external database"
You miss a lot of things in Sharepoint things like transaction support, referential integrity, easy way of updating (compare SQL), reporting (using Reporting Services and a SQL database)... see sharepoint as a way to store documents and simple lists.....
The argument for Sharepoint is if it is a small application, no requirements on support for transactions, no need to import external data etc...
When people say Sharepoint is a development plattform there is a need to define whjat they think a development plattform is.
The latest rumours about Sharepoint 2010 tells us that there will be support for SQL server based lists in next version ..... which I think will at least move Sharepoint in the right direction ....
Take a look at SLAM, SharePoint List Association Manager, an open source project my company created and actively supports. SLAM allows you to synchronize SharePoint data to SQL, including any relationships between lists. SLAM, in addition to being very useful on its own, is really a framework intended to allow developers to create their own complex data associations using what we call SLAM type profiles. We have one out-of-the-box type profile which is part of the open source project which actually allows you to make a SharePoint list hierarchical using the nested set model. For more information, see this page on our codeplex site.
I do this a lot just using sharepoint, using a framework called AAA (Activity,Assignment,Artifact), which allows you to use lookup columns to link an assignment or artifact to a parent Activity. You then build a web part page with connected web parts that allow you to filter all assignments and artifacts by activity. For example, click next to a submission in the submission web part, and all of the submission items attached to that submission will show up. Works great.
The other approach that you can look at using is persisting XML with a field in the item. This is the approach used by the Podcasting Kit (on CodePlex) to store things like ratings.
One possible method is to create a submission content type based on the folder content type and a submission-item based on item content type. Then you can store data hierarchically like in file system and also will work default views and search functionality.
Other way is to create lookup field that points to same list (list=”self”). This field will be used like reference to parent item and you will get list that contains recursively related data. To use this data programmatically will be ok but using views functionality will be little bit complex.
It's easy to do using a connected web part.
Create two lists:
Parent (Id, Title)
Child (Id, Title, ParentId)
Create a new sharepoint page, add DataFormWebPart (displaying Parent) and another one for Child, set both of them to filter based on a QueryString parameter (use that Parameter to filter Parent.Id, and Child.ParentId) voila, you can display parent-child relationships. Now, adding children is more difficult, and that's the part I haven't worked out yet.

SharePoint "Group By" is broken when using "Allow Multiple Values" for a column

I want to show the documents in my document library grouped by category. The category is a lookup column that I added that allows for multiple values. Unfortunately this breaks the "group by"-functionality completely. Is there a programmatic solution to this problem?
There is one way... It's complex and ugly - but it should work :)
It is possible for you to write you own view for at list (HTML, JavaScript and all). The VWSTYLES.xml file in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\XML folder, contains the HTML and JavaScript for the default SharePoint view styles - getting your inspiration from this, you can create your own view style, where you can do anything you want!
The problem is, that SharePoint don't have any way to deploy your custom view style - this is where the ugly part comes in - you have two options for deploying your view style.
Add you code directly to the VWSTYLE.xml/Edit a copy of it and override it with a feature
Pros:
You will still be able to edit the
view from the SharePoint interface
Cons:
You override a default SharePoint
file - your work can be overridden by
a SharePoint update.
Your view style will be available on every list in SharePoint.
Create your view programmatically on the list
Pros:
You don't override any default
SharePoint files.
You can control which list uses your
view
Cons:
You wont be able to edit the view thru the SharePoint interface
I've used method 2 a couple of times myself - and it works... but it's not pretty! :)
I don't think what you are trying to do is possible. When grouping items/documents, you display them in different groups based on a grouping value. I don't think SharePoint has support for adding a single item to multiple groups. With multiple values in the grouping field its' impossible to know which group to add the item/document to. I am not sure if this is an error or if it's by design.
Thomas is correct, this is by design as the item would have to appear multiple times in different groups. It is worth noting that this is possible via the web services, however.
See why I was getting duplicate rows from the sharepoint lists web service
And no, I've no idea why the lists webservice will do it, but the API won't.
Check out this link as well. Access supports this functionality without having to do much ugly code. http://office.microsoft.com/en-us/access/HA012337221033.aspx
So here is a sort of hack that has worked for me, no guarantees though. While your column (Office in my case) has allow multiple values enabled, fill in all of your data as needed. Once done, go to List Settings, click the Column "Office", and turn off allow multiple values. SharePoint will pop up a warning about how this data may be lost (never happened to me). Hit okay, then modify the view you want grouped, "Office" should now show up on the drop down of columns to group by. Finished result will result in your groups (and or sub groups) showing up just fine.
The only qualm I have is that instead of having an item show up in both Group A B because it had both field A and field B checked in Column X, it just creates a new group, Column X: A; B. So in my case, I have staff in both Beaufort and Orangeburg Offices, instead of having those staff in both groups (preferable) it creates a new group as below:

Resources