Run code with elevated permissions


We have a scenario where during in interactive session the user performs a specific action ( say submit ). The process here is restricted by the permission that the logged in user has for the doc-type. If as part of the submit functionality we also want the user to perform actions that require it to access documents that are not permitted to be read by this user how do we do it ? I’ve seen ignore_permission for but here I also need to read documents this user does not have access to . Is there any way to run code with elevated permissions to achieve this ?


On the backend side, like you mentioned, most of the document accept flags to ignore permissions.

Regarding reading with elevated permissions, frappe have 2 apis to read data.

One ensure permissions: frappe.get_list
The other didn’t: frappe.get_all

But frappé doesn’t offer impersonation capabilities, or role swapping capabilities, what can solve this.