4

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?

  • are you able to ever solve this? having same problem – Prashant Lakhlani Mar 1 '12 at 9:49
2

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.

0

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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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