- Strapi Version: 3.6.3
- Operating System: macOS Big Sur 11.2.1
- Database: PostgreSql
- Node Version: 14.16.1
- NPM Version: 6.14.12
- Yarn Version: n/a
Hi guys, I’m developing a facility request app and one of its main feature is to request office stationaries (and the request can be canceled).
The client wanted an automatic report for the stationaries stock flow, so I decided to log the stock flows in a table. There are 2 cases where this log will be created:
When a user requested stationaries from the frontend (Done by simply making a post request to the log table from the frontend)
When a strapi admin adds a new stock to an existing stationaries
I tried to do case 2 by creating a new entry for the log table in
beforeUpdate lifecycle and it works. However, this also causes the log to be created when a user cancels their stationaries request from the frontend (which updated the stationaries stock into its original number), which should not be recorded into the log.
Main question: Is there any way to limit the process in
beforeUpdate lifecycle so that it only executes when a strapi admin updates the stock?