Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Create new view powershell OrderBy Sort

$
0
0

Hello everybody.

I am creating a whole structute of spaces with PowerShell.

When I create a new view with powershell I use this code.

$viewFields = New-Object System.Collections.Specialized.StringCollection
$viewFields.Add("Type")
$viewFields.Add("Name")
$viewFields.Add("Modified")
$viewFields.Add("Modified By")
$query = "<OrderBy><FieldRef Name='Last Updated' Ascending='false' /></OrderBy>"
$view = $list.Views.Add("WebPartView", $viewFields, $query, 3, $false, $false)
$view.TabularView = $false
$view.Update()

Which is correct and working fine.
The question is about the Sort opcion. When I apply the sorting through the query, it is being stored there. I can check the item on PowerShell and the query is stored in the $view.Query property.
And after that, when I go to edit the view, there is no sorting applied (it is somehow inside the view, on the query level) so if someday I would like to change that sorting, it would not be possible.

How can I apply the sorting option with powershell, using the normal system (the one that later could be modified by editing the view) and not the query style?

Thanks all.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>