Is there a way to stop editing an item when the approval status is in the pending mode in SharePoint Online list? i.e. restrict users to change an item when it is waiting for the approval process. I have also access to Power Automate if I need to do anything specific there.
Why dont you set item level permissions in your workflow.
In your workflow once you start the approval process set the item level permissions as per your need (read access in your case).
Next check the outcome (i.e. if it is approved or rejected as per your condition) reset the item level permissions.
This way user will have only read only access to your item once the approval process starts. And once the item is approved/rejected (i.e. as per your requirement) you can again reset inheritance so that it will inherit permissions from the parent list. So the user will get accesses as it was before.
For locking purpose, you can check out this post: Locking a file for approval.
It uses custom flow process with Content Approval off and check out the document using flow.
In addition to the other Answer: if you want to change user permission using Flow, here is a blog that might do some help: Power Automate and SharePoint Permissions.
Thanks to both @Chelsea and @Rohit, the credit should go tho them, their answers were very helpful (as one upvoted and I accepted the other as the answer). However, for the sake of completeness I am posting the steps below:
Each list inherits its permission from the site and this must be broken if we need unique permission for each list, however, even if we do this and assign unique permission to each list, then each item of the list inherits the list permission. So, we need to break this inheritance, do the changes in item permission (as demonstrated in the link provided by Chelsea), and then restore it (as Rohit has mentioned).
To assign new permission to an item of a list, we need to have the PID of the group that we want to assign new permission. PID stands for Principal ID and is different for each user group. In here the author suggested sending a REST API and get this dynamically. This is helpful but I think there is a limit of 2k SP API calls per developer, so if we have lots of changes or lots of lists, we ran out of this. So, I created an Excel file and stored the list name, group name, and PID. To get the PIDs for the group list, I ran the below call:
I saved it in a notepad, rename the extension to XML and opened it with EXCEL, then removed the duplicates and came up with unique PIDs and group names. Then I added the list name (ListName) to this date and saved it in an Excel in SP like below (I have also added a column called "Site" for different use):
Note: all the members should be part of a group otherwise, you need to call the API for each individual user rather than once for the group.
Now, my flow looks like this: Ignore the condition, it is for my personal use
The details of breakinhertance and read excel are as follow: (you can use ONE filter expression in Excel too)
so we have removed the editing permission as there is no edit on top left and the number of groups have been reduced.
Now, the admin sees the request and approve it, the rest is easy, just we need to restore inheritance action after changing the approval status.
Everything is normal as it is supposed to be!:)