Hi everyone.
We have cloud code that filters users by some input parameters that are passed to this code through. Code works fine and returns result. For example 10 users from 11 filtered user. So in Android sdk I would like to get nextPage with last user. I call nextPage on the previously returned BackendlessCollection class and I get next page, but with all users (so no filter parameters comes through).
This is client code:
Object[] args = new Object[]{userTypeCode, experienceCode, ignoreExperience, gender, ignoreGender, doesTFP, ignoreTFP, isPublished, ignorePublished, isAgencySigned, ignoreAgencySigned, cityID};
BackendlessCollection collection = Backendless.CustomService.invoke( SERVICE_NAME, SERVICE_VERSION_NAME, "ppsdata", args, BackendlessCollection.class );
// totalObject is 11, items in data field count is 10
BackendlessCollection newCollection = collection.nextPage();
// expected: totalObject is 11, data count is 1
// actual: totalObject is 40, data is 10
If you still encounter the error - can you give us the steps that will reproduce the error? You can provide us the code you use - either here, or at support@backendless.com
Hi, MiG35.
You use case a bit wrong.
You initialize BackendlessCollection on the server side inside of server CodeRunner with BL secret key and other context information, and then you try use the same (already initialized) BackendlessCollection in other context - your current code. It wouldn’t work.
Make call as in previous post by Anatolii direct from you code.
So on Cloud Code collection we can’t call nextPage? May be you should remove this method or throw any exception on this call. Because it is not clear and expected.
I can’t use Anatolii answer because main logic is in Cloud Code, so generally application shouldn’t know what fields they should check and what where clause they should build. So we use cloud code pagination now (new additional parameters like pageNumber and pageSize).
nextPage can be used when you retrieved a collection of objects using Backendless native API, that means using something like this: (Backendless.Data.of( Foo.class ).find() ).
If a collection is retrieved from a custom service, the nextPage call will not work as expected.
Any way I think that you should write this information in docs and add exception on nextPage call, because this call can not work as expected in all cases.