Function in Web UI and function in Web SDK application returning two different results, sorted list response

I implemented some pagination logic and when I test with both the web UI (as well as a webhook created to debug this), I get my returned list sorted correctly. The expected response is that the list will be sorted by a name field, ignoring case. When calling with the Web SDK (app.currentUser.functions.functionNameHere), I can see the correct query being sent over the wire, but the response has the list sorted case sensitive (capitals first then lowercase). Nothing happens on my end during this call that could alter the response (no sorting or filtering on the js side).

The collection itself was re-created to specify the collation caseLevel: false, caseFirst: off , and strength: 1. This had no impact on the search itself, even though the field I’m sorting on is indexed as well using default collation.

As mentioned above, I even created a web hook to test this functionality in the odd event that something gets crossed during an http call. The results return sorted as expected.

At this point, I don’t know what else to try and test to get any additional details. Any help would be gratefully appreciated.

1 Like

The problem turned out to be that functions not run by System can’t actually use the collation specified in the collection. So if your function is running as Application Authentication, there’s (currently) no way to do what I was trying to do. So be sure to add any additional authentication logic to your function to ensure that the calling user is actually allowed to be calling that function.

It’s also worth noting that by default, when testing your functions in the web UI, the functions are run by System User and not the user logged in. This is why my tests were working, but calling it from the client side application was not producing the same results.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.