Sorting Best Practices
When you’re working with Matrix items, make sure the sorting values match between child and parent records. For sortable fields, set the same values in the child items as you do in the parent items. If the values don’t match, you’ll get inconsistent sorting results.
For example, if you add a custom field called Best Seller to your item record, but only set the value on the parent and not the children, sorting by Best Seller might not show the parent records where you expect.
Note that parent items are assigned a sort value defined as the lowest sort field value from among their children. The parent items are then sorted according to those selected sort values.
Combine Sort Fields Using Item Search API
Even though the default sort order is by relevance, you can change it by using a custom item field along with relevance. This helps when two or more items have the same relevance score and you want to use another field as a tie breaker. For example, you could use Most Popular or Best Seller as the extra parameter.
Since API calls override NetSuite’s default settings, you can use an Item Search API request to combine multiple sort fields and show the results you want.
For example, suppose you add a custom field, Rating (custitem_rating
), to your item record to record the item review rating. Enter a value in the custom field on item records, assigning numbers 1 – 5, with 5 being the best rated item. Then, use an Item Search API request to sort by price and rating.
/api/items?sort=pricelevel5:asc,custitem_rating:desc
For information about Item Search API, see Item Search API. For the complete list of parameters supported by the Item Search API, see Item Search API Input Parameters.