Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top