Back

How to get oldValue and Current value in function

  • 0
  • Functions
PrasenjeetKr
4 Jun, 2023, 16:12

My function is executed after the document update , how i can get the oldValue and Current Document in the cloud function ?

TL;DR
The user wants to know how to get the old and current values in a function. They mention that the value they need is in `req.variables.APPWRITE_FUNCTION_EVENT_DATA`. Currently, only the updated values are available. They mention a requested feature and provide a link to upvote it. They also mention a workaround suggestion by Steven, which can be found in this link: https://github.com/appwrite/appwrite/discussions/5615#discussioncomment-6071506. The user asks how they can get the old and current document in the cloud function.
Binyamin
4 Jun, 2023, 16:16

For now you'll get only the current-updated values of the document.

This is a requested feature, you can check about it here (and upvote): https://github.com/appwrite/appwrite/issues/3294

The quick workaround would be what Steven's suggesting here https://github.com/appwrite/appwrite/discussions/5615#discussioncomment-6071506

PrasenjeetKr
4 Jun, 2023, 16:30

and that value is in the req.variables.APPWRITE_FUNCTION_EVENT_DATA ?

PrasenjeetKr
4 Jun, 2023, 16:30

as a whole document ?

PrasenjeetKr
4 Jun, 2023, 16:31

I have to do some extra work for this to work . Okay thanks

Binyamin
4 Jun, 2023, 16:31

Yes.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more