Refresh detail view after update

Hi,

We have a problem with update action. Our entity has several fields, we change one and save but as business logic side effect another field changes value also. The problem is that after performing a successful update on the entity details page only field that we have changed is updated and not also the dependent one. If we refresh the page, all values are updated. Is there a way to reload the entity details page after performing an update?

Thank you very much.

1 Like

Hi @Antonije_Pavlovic and welcome :champagne: ,

Could you share a video so I can better understand what you want :angel:?

Hi Vince,

Features permissions are computed field and it is not editable. When we add a feature to additionalFeatures backend logic adds it to features permission field. This change is not reflected after save and we need to perform refresh, you can see it in the attached video.

You can access video on the following link: https://imgur.com/55polCY

Okey it’s pretty clear now.
Did you override the route ? Or is it a smart field ?

We have overridden route and we are calling our API that performs update.

Okey then can you share this overridden route it might miss a piece of code :wink:

const { organizations } = require('../models');
const { RecordUpdater } = require('forest-express-mongoose');


router.put('/organizations/:id', async (request, res) => {
  const recordUpdater = new RecordUpdater(organizations);
  const recordToUpdate = await recordUpdater.deserialize(request.body)

  const id = recordToUpdate._id;
  delete recordToUpdate._id

  await moleculer.call('iam.organization.update', {
    filter: {
      _id: id,
    },
    update: recordToUpdate
  });

 res.status(200).send('Organization updated')
});

Okey so the issue is here. Look at the documentation
You must return the record to update it. Here you just return Organization updated

router.put('/organizations/:id', async (request, res) => {
  const recordUpdater = new RecordUpdater(organizations);
  const recordToUpdate = await recordUpdater.deserialize(request.body)

  const id = recordToUpdate._id;
  delete recordToUpdate._id

  await moleculer.call('iam.organization.update', {
    filter: {
      _id: id,
    },
    update: recordToUpdate
  });

 const recordSerialized = await recordUpdater.serialize(record);
 res.send(recordSerialized);
});

Try that and tell me if that fixes your issue :wink: