# Problem updating app metadata in onExecutePreUserRegistration action

**URL:** <https://community.auth0.com/t/problem-updating-app-metadata-in-onexecutepreuserregistration-action/74151>\
**Category:** Get Help\
**Created:** [December 2, 2021, 8:03pm UTC](https://community.auth0.com/t/problem-updating-app-metadata-in-onexecutepreuserregistration-action/74151 "2021-12-02T20:03:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott8](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/scott8/32/12829_2.png) [@scott8](https://community.auth0.com/u/scott8)\
**Post date:** [December 2, 2021, 8:03pm UTC](https://community.auth0.com/t/problem-updating-app-metadata-in-onexecutepreuserregistration-action/74151/1 "2021-12-02T20:03:57Z")

</div>

I am having a problem converting a pre-registration hook to a pre user registration action.

The problem is I cannot seem to update the user.app\_metadata. Refer to the code below. What is happening before this is we are calling our system to create the user and get a user id and some account information. That is all working wonderfully. To debug I show the user before and after I attempt to update

console.log(‘before user update’);  
console.log( event.user);  
//this data below looks all good coming back from our system  
console.log( resp.body.app\_metadata.a\_id);  
console.log( resp.body.app\_metadata.u\_id);  
console.log( resp.body.app\_metadata.role);  
//I tried this first and it did update the user in the console.log but not when looking at user after  
//event.user.app\_metadata = resp.body.app\_metadata;

//so I then tried this:  
api.user.setAppMetadata(“a\_id”, resp.body.app\_metadata.a\_id);  
api.user.setAppMetadata(“u\_id”, resp.body.app\_metadata.u\_id);  
api.user.setAppMetadata(“role”, resp.body.app\_metadata.role);

console.log(‘after user update’);

//here app\_metadata still shows as an empty JSON object  
console.log(event.user);

//the user when inquiring after the fact also shows no app\_metadata

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 7, 2021, 12:58am UTC](https://community.auth0.com/t/problem-updating-app-metadata-in-onexecutepreuserregistration-action/74151/3 "2021-12-07T00:58:24Z")

</div>

Hi @scott8,

Thanks for reaching out to the Auth0 Community!

I understand that you’re trying to migrate from Auth0 Hooks to Actions and have issues updating the user’s app\_metadata.

After testing your code snippet, I can confirm that it works and the user’s app\_metadata is being updated with the correct information. You can verify by checking the user’s profile either on the Auth0 Dashboard or with the Management API v2 Get a user endpoint.

Now, if you plan on using the new metadata for additional logic, you’ll need to use `event.user.app_metadata = resp.body.app_metadata;` as well to be able to see the current user’s app\_metadata.

Hoped this helps!

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 22, 2021, 12:59am UTC](https://community.auth0.com/t/problem-updating-app-metadata-in-onexecutepreuserregistration-action/74151/4 "2021-12-22T00:59:12Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
