Smart search order by

Brenden Kehren asked on September 30, 2015 07:03

Pretty trivial question here but I can't seem to get the out of the box smart search results to order by a query string value. I have a query string parameter of sort and it's value is a column name like firstname, lastname, createdate, etc. When I use the macro {?sort?} in the order by clause for the webpart, it doesn't sort the results. Could this be because I have it searching each time the webpart loads?

Correct Answer

Brenden Kehren answered on October 1, 2015 01:14

Thank you both for your answers. Looks like the problem was not enabling the search fields on the object. See Juraj's answer toward the bottom of the post. After I went in and enabled the fields I'm sorting by in the Search column, the sorting worked.

1 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on September 30, 2015 15:10

Hi Brenden,

(if you don't know I'm afraid nobody knows :) )

But some thoughts:

  • Have you tried casting the return type to string (to be sure)
  • sql or macro debug to see what actually gets fired
  • are the column's actually available in your select

David

1 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on September 30, 2015 20:58 (last edited on December 10, 2019 02:30)

Everyonce in a while I have issues with the {% %} macros. One thing I usually will try, which usually works is to use this syntax instead.

{% QueryString.GetValue("key") |(identity)GlobalAdministrator%}

If the issue isn't in the macro, then you may need to have a script running at the server level to set the sort property on the page load or the reload data method. Depends on what is in that webpart. You could also customize the webpart by cloning it and then you could have full control, which probably would be pretty easy, as you can get the querystring value and then set the property from there as well. Not sure if that will work or not, but may be worth a try.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.