Solved

SharePoint - PowerShell CAML query sorting on Due Date

Posted on 2011-09-19
9
2,359 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

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)

Join & Write a Comment

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now