문제

What is the best way of updating views on a production environment? Assume you roll out a second version of your sharepoint solution and you want to add/modify the views on the list, but you can't just redeploy the list, because it contains production data.

Is it a good idea to update the views via the sharepoint object model? Or are there better ways to update views without touching the underlying list?

Thanks for any advice.

Update:

I accepted Anders Rasks answer. However I'm still looking for a simpler (more efficient) approach for view upgrades. Please post if there is a new solution for this out there... Thanks

도움이 되었습니까?

해결책

To do this i would recommend programmatically adding a view programmatically. You should do this in a feature call-out. Make the feature dependable on the original feature that created the view to avoid race conditions if you later decide to activate both features on a new site or need to recreate your farm.

In general i have moved away from doing lists and views declaratively as much as possible. Its only a few lines of code compared to a bucket full of CAML spit ;-)

Programmatically adding views is done using SPViewCollection.Add method. Heres a good example from SharePoint DEV Wiki: Creating a List View programmatically using the object model

More on creating call-outs from a feature receiver: http://www.sharepointdevwiki.com/display/public/How+to+add+a+Feature+Receiver+to+a+Feature

EDIT: SharePoint 2010 supports versioned features. This will allow you to branch updates based on feature version. One option is to add fields to existing content types:

hth Anders Rask

다른 팁

Depending on what your application is, once you're in production the application is going to be changing dynamically due to user activity (assuming it's at all successful). Why wouldn't you just go to the SharePoint UI and make the changes to the view there? Is this a case of over-developer thinking or am I missing a requirement?

you can also create view on dev/staging environment and then copy ASPX file to the production.Just be sure to set correct list guid.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top