Solved

SharePoint - PowerShell CAML query sorting on Due Date

Posted on 2011-09-19
9
2,410 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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