SP 2010 Query CAML - How to sort by multivalue colum lookup field?

1.6k views Asked by At

I'm trying to sort a list where a column is based on multiple value on a lookup field with the following statement:

<OrderBy>
  <FieldRef Name='LookupFieldName' Ascending='TRUE' LookupValue='TRUE' />
</OrderBy>

If I uncheck "Allow multiple values" from column settings it works fine, but not with multiple values enabled.

Have you some suggestions?

Why SP can't sort on concatenation of ID#Value (eg. 1#Value1;2#Value2) ?

Thanks

1

There are 1 answers

0
Steve Mannina On

You should be able to treat the addtional columns as any other column. In this example, Attorney1_x003a_EmpID is one of the multiple values:

<Query>
    <OrderBy>
         <FieldRef Name="Attorney1" Ascending="False" />
         <FieldRef Name="Attorney1_x003a_EmpID" Ascending="False" />
    </OrderBy>
</Query>