0

I want to create a calendar view in a calendar list using CSOM power shell for SharePoint online.

I am able to create a view using PowerShell but the calendar columns are not set. I want to set the below values using CSOM:

<ViewData>
  <FieldRef Name="Title" Type="CalendarMonthTitle" />
  <FieldRef Name="Title" Type="CalendarWeekTitle" />
  <FieldRef Name="Location" Type="CalendarWeekLocation" />
  <FieldRef Name="Title" Type="CalendarDayTitle" />
  <FieldRef Name="Location" Type="CalendarDayLocation" />
</ViewData>

View.Viewdata property is used in server side to set the above values, I need it in client side.

0

I appreciate this a bit late, but this may help someone. You can update the viewdata property of a view on the client-side with something along these lines:

$siteURL = "http://sp.myfirm.com/fwc"  
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)  
$view = $ctx.web.Lists.GetByTitle("Firm-wide Calendar").Views.GetByTitle("Calendar")          #View name you want to customise
$view.ViewData="<FieldRef Name=""ColourTitle"" Type=""CalendarMonthTitle""/><FieldRef Name=""ColourTitle"" Type=""CalendarWeekTitle""/><FieldRef Name=""FCLocation"" Type=""CalendarWeekLocation""/><FieldRef Name=""ColourTitle"" Type=""CalendarDayTitle""/><FieldRef Name=""FCLocation"" Type=""CalendarDayLocation"" />"
$view.Update()  
$ctx.Load($view)   
$ctx.executeQuery()

As you can see, the viewdata property just needs the XML markup, minus the viewdata tags.

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.