Error while setting sort properties in search

Jun 13, 2014 at 8:46 AM
I have a problem while setting sort properties.

The code that I wrote;

var search = Microsoft.SharePoint.Client.Search.Query;
var ctx = SP.ClientContext.get_current();

var query = new search.KeywordQuery(ctx);
query.set_queryText(queryText);
query.set_rowLimit(10);
query.set_trimDuplicates(false);

query.set_enableSorting(true);
var sortProperties = query.get_sortList();

var sortItem = new Microsoft.SharePoint.Client.Search.Query.Sort();
sortItem.set_property("modifiedby");
sortItem.set_direction(Microsoft.SharePoint.Client.Search.Query.SortDirection.descending);
sortProperties.add(sortItem);

It returns the following error message:

"Property doesn’t exist or is used in a manner inconsistent with schema settings."


If I change the code in generated .js file as follows. then it works.

var sortProperties = query.get_sortList();
sortProperties.add("modifiedby", 1);

How can I solve this problem?

Thanks for your feedback
Jun 13, 2014 at 1:37 PM
I found the problem and opened a new issue to fix it.
Signature of Add method in SortCollection class should be changed.

Regards
Coordinator
Jun 15, 2014 at 7:32 PM
Bug is fixed, update SharePoint.d.ts from repository on CodePlex. New version on nuget will be published soon.