Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have something like this:

SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef name=\"MyTerm\" /></OrderBy>";
myList.GetItems(query);

I can sort on normal fields, but it refuse to sort on my managed metadata field. Any ideas?

share|improve this question
    
are you able to ever solve this? having same problem –  Prashant Lakhlani Mar 1 '12 at 9:49
add comment

2 Answers 2

up vote 2 down vote accepted

One thing I've noticed in 2010 is that the OrderBy won't work if you're not returning the field name explicitly in the query.ViewFields property. So try adding:

query.ViewFields = "<FieldRef name=\"MyTerm\" />";

to your code.

share|improve this answer
    
Thanks for you answer. I tried this, but without luck. As well as setting query.ViewFieldsOnly = true; (ref mansoftdev.wordpress.com/2010/11/06/…) –  eirikb Nov 29 '10 at 19:18
add comment

Maybe you can try to write 'name' as 'Name'. Does the column allow multiple values?

share|improve this answer
    
Not sure if 'Name' instead of 'name' would help when it works for other fields? The managed metadata field can have multiple values in this case, yes. We finally ended up just using jQuery for sorting with fallback to no sort. We also use paging with jQuery since paging + filtering is difficult –  eirikb Feb 23 '11 at 11:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.