1

I know how to create a view via ViewCreationInformation class using client SP model. But how I can specify a url for this view ? Is it possible ?

In other words:

var test = _list.Views.GetByTitle("desiredView");
ClientContext.Load(test, t=>t.Title, t=>t.Id, t=>t.ServerRelativeUrl);
ClientContext.ExecuteQuery();

ServerRelativeUrl has only getter unfortunately

4
  • Append your List url with newly created view name. Like, mysite.sharepoint.com/sites/Testsite/Lists/LISTNAME/… – Vishnu S Oct 16 '17 at 12:41
  • but i just want to change a url for view – isxaker Oct 16 '17 at 12:48
  • Get list url by "_list.RootFolder.Name". Then append it with "desiredView" name. May be this will help. – Vishnu S Oct 16 '17 at 13:02
  • Yes, you are right. View's url usually looks like that. But my question is how to change this ulr programmatically ? – isxaker Oct 16 '17 at 16:21
1

View Url could be updated like this via CSOM API:

var viewPageUrl = "/Shared Documents/Forms/AllItems.aspx"; //existing view page url
var viewPageUrlNew = "/Shared Documents/Forms/AllItemsNEW.aspx";

var list = ctx.Web.Lists.GetByTitle(listTitle);   
var view = list.Views.GetByTitle(viewTitle);        
var page = ctx.Web.GetFileByServerRelativeUrl(viewPageUrl);
page.MoveTo(viewPageUrlNew,MoveOperations.Overwrite);
view.Update();
ctx.ExecuteQuery(); 
0

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.