1
votes

I am quering a sharepoint list using CAML query. Here i am using Order by condition on one list column. There is a chance of having null values in order column, at this scenario I want to Order the list using another list column (ex: Title column'). How to add this Order by condition in caml query to fetch the sharepoint list items.

My Code is:

 query.ViewXml = "<View><Query>";
 query.ViewXml += "<OrderBy><FieldRef Name='" + orderBy + "'/></OrderBy>";

 query.ViewXml += "<Where><Eq><FieldRef Name='" + fieldRef + "'/><Value Type = '" + type + "'>" + value + "</Value></Eq></Where>";
            query.ViewXml += "</Query></View>";
1

1 Answers

1
votes

You can have multiple fields in the OrderBy-section:

"<OrderBy><FieldRef Name='" + orderBy + "'/><FieldRef Name='" + orderBySecondary + "'/></OrderBy>"

This will be equivalent to: Order by 'orderBy' Then By 'orderBySecondary'