3

I can't figure out how to create a solution in Visual Studio 2010 that will allow me to alter existing lists in a SharePoint 2010 site. Specifically, I want to add a new column, which contains a small icon, to existing document library lists. I want to be able to take an action when someone clicks on one of the new icons. I also want this new column to become part of the default view for new document library lists. All of this needs to be easily deployed to a SharePoint 2010 site via a .wsp file.

Extensive searching on Google has shown how to create new lists and new column types, and how to programmatically add columns to one of the new lists, but not how to modify all existing lists. (I have seen some code snippets that look promising, but am not really sure where to put them or if it's applicable to a .wsp file.)

I'm brand new to SharePoint, so any pointers towards a solution would be much appreciated. Thanks!

4 Answers 4

1

The only way you're going to be able to add a column to all currently existing document libraries is to modify the Document Content Type, which isn't a recommended customisation (purely because any future service packs may override any and all changes you make).

If you're wanting users to be able to perform an action for each item in a list, then you could probably look at adding a Custom Action to the Edit Control Block (ECB) menu (which appears when you click on the arrow to the right of a document's title).You can apply this customisation to Lists of a specific List Type, and in your case you'd tie it to the Document Library List Type.

(I've capitalised the important words to help you on your Google Searching :) )

2
  • Thanks for the help! I've been re-tasked to something else for a bit, but will be sure to try this when I get back to SharePoint, and say how it goes.
    – user1608
    Commented Oct 13, 2010 at 16:48
  • I think an ECB customization is the best solution.
    – Steve P
    Commented Dec 7, 2010 at 20:30
0

You can go with feature receiver approah here. So you will have two parts of in solutions:

  1. Code that adds your columns to a given library object and to the default view of the library.
  2. A feature receiver that gets the collection of all the document libaries in the current web and further calls the method in #1 by suppllying the currently iterated SPList object.
1
  • As in the comment above, thanks! I'm looking forward to being able to try these out.
    – user1608
    Commented Oct 13, 2010 at 16:50
0

I would do it in powershell.

Check this out

0

Basicly you could also just itterate through all the lists in your web. Check wether its a Document Library or not, incase it is... Add a new column... This can be done using vs2010 or ps. Tho editing the Content Type might be better :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.