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?

1
  • are you able to ever solve this? having same problem Mar 1, 2012 at 9:49

2 Answers 2

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.

1
0

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

1
  • 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, 2011 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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