SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you with CAML provision a View to a already existing list? I know how to add views through list definitions.

share|improve this question

You can't add a view to a list using the declarative model as you would in a list definition. The best way to do this would be in a Feature Receiver, using .NET code.

share|improve this answer
Sounds good, could you dive into some more details please? If I understood you correct I should write some CAML as in a list definition. But how do I apply It to a list through code? Isn't there a way to apply it declarative? – Tim Jun 20 '12 at 16:34
No CAML. You'll need to write code. Get a new SPView, add the columns using myView.Add("Title"), for example. – Derek Gusoff Jun 20 '12 at 16:45
OK, never mind, I may stand corrected. According to this blog, you might be able to add the CAML to the SPView's Query – Derek Gusoff Jun 20 '12 at 16:48
Thank you, the blogs information looks promising. Will dive into it when I got some time over for it! – Tim Jun 20 '12 at 17:05

I think you can do like here : Specifying advanced webpart properties on a view in a custom module?

share|improve this answer
Im sorry, I think the correct term to use in my question is View, and not ListView, which I used. The Code you refer to instancitetes a XsltListViewWebPart. Which is something different from what I'm trying to achieve. – Tim Jun 20 '12 at 16:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.