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
Solved

SharePoint - PowerShell CAML query sorting on Due Date

Posted on 2011-09-19
9
2,446 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
I have just recently built a new SharePoint 2007 farm on a complete Windows 2008 R2 server platform and part of my standard build procedure is to implement a warm up routine, usually in the form of a script that is scheduled every morning to launch …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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