1

How to set the url title of a list view programmatically (preferrably CSOM/JSOM) so we could for example create a view whose View Name is "My View" and its web address ends with "/MyView.aspx"

enter image description here

3

Following code sample should help:

SP.ViewCreationInformation viewCreationInformation = new SP.ViewCreationInformation();
viewCreationInformation.Title = "My View";
viewCreationInformation.ViewTypeKind = SP.ViewType.None;
viewCreationInformation.RowLimit = 30;

//Make sure that the name of the fields should be equal to 1 any of the associated SiteColumns Internal Name. The Fields in the view will appear in the same order as declared here.
viewCreationInformation.ViewFields = new string[]{"Title","Created","Modified"};
viewCreationInformation.SetAsDefaultView = true;

oList.Views.Add(viewCreationInformation);

ctx.Load(oList.Views);
ctx.ExecuteQuery();

If you want the URL and Title to be different, you might need to play a trick with SharePoint..

That is first create the view with title "MyView" and then get the view again and update the Title value to "My View"..

  • Can we change the url of an existing view? – thomius Apr 21 '14 at 11:53
  • I don't think that is possible.. SharePoint stores the URL and even if you update the Title, it won't change the URL.. – Arsalan Adam Khatri Apr 21 '14 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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