SharePoint - PowerShell CAML query sorting on Due Date

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?
LVL 1
shawnsouthernAsked:
Who is Participating?
 
shawnsouthernConnect With a Mentor Author Commented:
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
 
mwochnickCommented:
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
 
shawnsouthernAuthor Commented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mwochnickCommented:
weird, can you get it to sort using another field?
0
 
mwochnickCommented:
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
 
shawnsouthernAuthor Commented:
I can sort by AssignedTo without a problem.  I've tried Due_x0020_Date and Due%20Date and neither make a difference.

0
 
shawnsouthernAuthor Commented:
I can also sort by the 'Created' field without problems.  It appears that just the 'Due Date' field is causing a problem.
0
 
mwochnickCommented:
wow I hate that - glad you found it though
0
 
shawnsouthernAuthor Commented:
My comment is the correct solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.