update another users' property

Hi Backendless!

trying to make one user “like” another users’ profile.

my thought was that if the user presses the “like” button, it will add 1 to the other users’ “like” property.

but I’m not sure how to update a property of the other user while I’m obviously connected as the first user.

please help.

thanks,
Gil.

To update user object property, you need to use the setProperty method on the BackendlessUser object:

https://backendless.com/documentation/users/android/users_user_properties.htm

Regards,
Mark

Hi Mark,

yes I know how to update my users’ properties :slight_smile: I mean how to update ANOTHER user property. update user A property, while I’m connected as user B.

To update another user property, you need to use another user object. To update user B, you need to have an instance of BackendlessUser class which references user B.

yes but how do you make the connection between the other user class:

userB.setproperty(“the best backend service”, Backendless);

and updating Backendless:
Backendless.UserService.update(userB, new AsyncCallback<BackendlessUser>() {how does Backendless know that I want to update that specific user ? do I need to put the ObjectId ? like:userB.setproperty(“ObjectId”, userBObjectId);
userB.setproperty(“the best backend service”, Backendless);Backendless.UserService.update(userB, new AsyncCallback<BackendlessUser>() {

Backendless knows that it is a specific object by objectId. When you save an object, we check if objectId is assigned, in that case it is an update operation, otherwise if there is no objectId, it is a create operation.

Thanks Mark, so what I wrote was true? You set a property of userB’s ObjectId and then the property you really want to update and Backendless knows to update userB according to that?

You showed a brief snippet of the code that I could not understand. Please keep in mind we do not review your code here, but instead can help with the APIs and backend related question.

resolved it.
now have a working “like” system.
thanks Mark for all the help.

Dear Mark,

tried doing what you’ve suggested, but I get an error message saying “Unable to update user account due to error: Can not get user schema”

this is my code:

final BackendlessUser ouser = new BackendlessUser();
   ouser.setProperty("ObjectId", currentListData.getUserobjectId());
   ouser.setProperty("likes", 1);
   Backendless.UserService.update(ouser, new AsyncCallback&lt;BackendlessUser&gt;() {
       @Override
       public void handleResponse(BackendlessUser backendlessUser) {
           Log.i(TAG, ouser.getProperty("likes").toString());

       }

       @Override
       public void handleFault(BackendlessFault backendlessFault) {
           Log.i(TAG, backendlessFault.getMessage());
       }
   });

please help.

Hi Gil , how did you resolved it?
I have the same problem. I want to update a different user property and I get “Could not find user by id or identity” with your method…

Thanks.