Solved

SharePoint - PowerShell CAML query sorting on Due Date

Posted on 2011-09-19
9
2,521 Views
Last Modified: 2012-05-12
This is my Query:

$query.Query = "<OrderBy><FieldRef Name='Due Date' Ascending='TRUE'/></OrderBy><Where><Neq><FieldRef Name='Status' /><Value Type='Text'>Completed</Value></Neq></Where>"

It returns all of the items that are not 'Completed' but does not sort them on the 'Due Date' field.

What else needs to be done?
0
Comment
Question by:shawnsouthern
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 12

Expert Comment

by:mwochnick
ID: 36563026
it may be a case of picky syntax and btw Ascending=True is the default so you could try

$query.Query = "<OrderBy><FieldRef Name='Due Date' /></OrderBy><Where><Neq><FieldRef Name='Status' /><Value Type='Text'>Completed</Value></Neq></Where>"
0
 
LVL 1

Author Comment

by:shawnsouthern
ID: 36563199
That had no effect on it.  

I'm wondering if it, for some reason, needs something else to access the 'Due Date' field.

The list is just a typical SharePoint task list.  My PowerShell script does everything I want it to, except it doesn't sort these results!
0
 
LVL 12

Expert Comment

by:mwochnick
ID: 36563433
weird, can you get it to sort using another field?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 12

Expert Comment

by:mwochnick
ID: 36563613
I found something that said spaces weren't allowed in field names  - try this

$query.Query = "<OrderBy><FieldRef Name='Due_x0020_Date' /></OrderBy><Where><Neq><FieldRef Name='Status' /><Value Type='Text'>Completed</Value></Neq></Where>"

post I found it on was here
http://www.devx.com/dotnet/Article/31762/1954
0
 
LVL 1

Author Comment

by:shawnsouthern
ID: 36566618
I can sort by AssignedTo without a problem.  I've tried Due_x0020_Date and Due%20Date and neither make a difference.

0
 
LVL 1

Author Comment

by:shawnsouthern
ID: 36566887
I can also sort by the 'Created' field without problems.  It appears that just the 'Due Date' field is causing a problem.
0
 
LVL 1

Accepted Solution

by:
shawnsouthern earned 0 total points
ID: 36567123
Apparently to sort on the Due Date field, the field name is 'DueDate'.

Now if there was any way to get those hours of my life back...
0
 
LVL 12

Expert Comment

by:mwochnick
ID: 36567153
wow I hate that - glad you found it though
0
 
LVL 1

Author Closing Comment

by:shawnsouthern
ID: 36902268
My comment is the correct solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question