The process of building custom solutions for SharePoint Server.
You could take a reference to the SharePoint approval workflow and set these options as the workflow start options.
Then the workflow will be triggered automatically when a new item is created or an item is updated.
All about Approval workflows
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.