# How to do an action AFTER a PUT update on a document?

**URL:** <https://community.forestadmin.com/t/how-to-do-an-action-after-a-put-update-on-a-document/2459>\
**Category:** Help me!\
**Tags:** howtos\
**Created:** [May 7, 2021, 6:51pm UTC](https://community.forestadmin.com/t/how-to-do-an-action-after-a-put-update-on-a-document/2459 "2021-05-07T18:51:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnaudambro](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaudambro/32/1480_2.png) [@arnaudambro](https://community.forestadmin.com/u/arnaudambro)\
**Post date:** [May 7, 2021, 6:51pm UTC](https://community.forestadmin.com/t/how-to-do-an-action-after-a-put-update-on-a-document/2459/1 "2021-05-07T18:51:19Z")

</div>

Hi there,

When I update one document (a user for instance), I need to update also this user to a third party service.  
In this regard, I wrote something like that

```javascript
// Update a User
router.put('/user/:recordId', permissionMiddlewareCreator.update(), async (request, response, next) => {
  // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record
  if (!request.params.recordId) return next();
  const user = await UserObject.findById(request.params.recordId);
  await thirdparty.updateUser(user);
  next();
});

```

but the `user` here is the one BEFORE the update, and I need the one AFTER, how can I do ?

I tried to look for an answer in the previous topics, but couldn’t find any…

thanks !

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [May 10, 2021, 8:26am UTC](https://community.forestadmin.com/t/how-to-do-an-action-after-a-put-update-on-a-document/2459/2 "2021-05-10T08:26:42Z")

</div>

Hey (again 🙂 ) @arnaudambro,

We have some documentation explaining the exact code triggered when doing an update (And all the other routes as well) [here](https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#update-a-record).

```javascript
  const recordUpdater = new RecordUpdater(companies);
  recordUpdater.deserialize(request.body)
    .then(recordToUpdate => recordUpdater.update(recordToUpdate, request.params.recordId))
    // The next promise receives as parameter the updated record 
    // You should be able to use `thirdparty.updateUser(record)` here
    .then(record => recordUpdater.serialize(record))
    .then(recordSerialized => response.send(recordSerialized))
    .catch(next);

```

Let me know if that helps!
