User or App Metadata was not Updated in Actions
Last Updated:
Overview
The Action code assigns a value to event.user.user_metadata["hoo"].
console.log(event.user.user_metadata["hoo"]) // Outputs "Original Value"
event.user.user_metadata["hoo"] = "Updated Value"
However, the following Actions do not get this updated value.
// In the next Action...
console.log(event.user.user_metadata["hoo"]) // Still outputs "Original Value"
The same goes for event.user.app_metadata["hoo"].
Steps to reproduce
- Create 2 Post Login Actions. Say Action 1 and 2. And add them to the flow.
- In Action 1, assign a value to event.user.user_metadata["hoo"] or app_metadata["hoo"]
- In the following Action 2, check the value of event.user.user_metadata["hoo"] or app_metadata["hoo"] (using Realtime Webtask Log)
Applies To
- User Metadata
- App Metadata
- Actions
Cause
Assigning a value to event.user.user_metadata["hoo"] or app_metadata["hoo"] will not update the source user data in the database.
Solution
(setAppMetadata for app_metadata)
//Action 1
api.users.setUserMetadata("hoo", "Updated Value")
//Action 2
console.log(event.user.user_metadata["hoo"]) // Outputs "Updated Value"