Backendless Support
 
Answered

Get user data before update business logic

How can I get User data before update, I want to compare data in business logic

I call methods beforeUpdate and afterUpdate, both return new value

Leave a Comment

Comments (8)

photo
1

Hi Ihor

I'm not sure that I understood you correctly. Could you please provide some additional info:

1. What is the final goal? You are updating property A in the Users table, and you want to get the old value of A property (before it was updated) and then to get the updated value of the same property?

2. How do you call beforeUpdate and afterUpdate methods?

Regards Anton

photo
1

I want to get value before it was updated and after it was update and compare them.

I don't call this methods, they call automatically, this is server side logic

photo
1

Are you using backendless 3 or 4?

photo
1

I am using backendless 3

photo
photo
1

Got it. I'll try to reproduce the behavior you've described and respond back ASAP

Regards Anton

photo
1

Ok, thanks, i'm waiting for response, because it is very important for me

photo
1

Ok, I figured out how to implement what you need. If you will try to extract the old value from userValues in beforeUpdate you will be receiving the updated value.

If you need to get the old value - call

  1. Backendless.Data.of(Backendless.User.class).findById("xxxx-yyyy-zzzz-cccc-qqqq").getProperty("name");

or extract the value of required property from current user if it's logged in.

No changes required in afterUpdate code.

Regards Anton

photo
1

Thanks