Support Topics Documentation Slack YouTube Blog

Query to Users Table

(Nathan23) #1

Hi friends,

  • I want to retreive Users Table object from other Project and this is what I’m doing
    Backendless.Data.of(BackendlessUser.class).findById(“objectId_fromOtherUserProject”, new AsyncCallback<BackendlessUser>() {
    public void handleResponse(BackendlessUser response) {
    BackendlessUser otherUser=response;

public void handleFault(BackendlessFault fault) {

At the end my otherUser variable is null.
First of all I’m not sure if that’s the proper way to get data from other project and UsersTable object.
Please your help.
Thanks a lot!!

(Sergey Chupov) #2

Hi Nathan,

Where in your code do you check the value of otherUser? Note that the request is asynchronous and the otherUser variable will not be initialized immediately after you call findById.

(Nathan23) #3

Hi Sergey , thanks for the response, but I check otherUser variable after find method, but it still null.
The following is the scenario I have issues:
helperBackend is empty after call Backendless.Data.of(BackendlessUser.class)…
‘response’ is a list of objects that have email property that are the same emails from the table Users which I want to retrieve data.

List<BackendlessUser> helperBackend = BackendlessHelperUtils.findHelpersFromBackend(getApplicationContext(), response);

public class BackendlessHelperUtils {

public static List<BackendlessUser> findHelpersFromBackend(Context context, List<Helper> list) {
Backendless.initApp(context, BackendlessSettings.APPLICATION_ID_HELPERS, BackendlessSettings.ANDROID_SECRET_KEY_HELPERS);
final List<BackendlessUser> auxListaHelper = new ArrayList<>();

for (Helper helper : list) {
StringBuilder whereClause = new StringBuilder();
DataQueryBuilder dataQueryBuilder=DataQueryBuilder.create();
Backendless.Persistence.of(BackendlessUser.class).find(dataQueryBuilder, new AsyncCallback<List<BackendlessUser>>() {
public void handleResponse(List<BackendlessUser> response) {
if (response!=null && response.size()>0){
public void handleFault(BackendlessFault fault) {

return auxListaHelper;

I can’t understand why that happen, I’m using ‘com.backendless:backendless:5.1.0’ as dependency.

Please you help.
Thanks a lot.

(Sergey Chupov) #4

From what I see in your code, you’re effectively returning an empty auxListaHelper list from the method, because the find call is asynchronous and most probably it hadn’t enough time to fill up the list with the response.