When deleting a doctype, I'm getting a permission error

frappe.delete_doc(“city”, city_name)

“exc_type”: “PermissionError”,
“error”: “Error: User not allowed to delete city: surat”,
“_server_messages”: “["{\"message\": \"User permissions: [‘Guest’]\", \"title\": \"Message\"}", "{\"message\": \"User Guest does not have access to this document\", \"title\": \"Message\"}", "{\"message\": \"User not allowed to delete city: surat\", \"title\": \"Message\", \"indicator\": \"red\", \"raise_exception\": 1}"]”


Hi @Priyank_Suthar,

The user is having a problem deleting a city because they don’t have the right permissions. To fix this, you can use the following code:

frappe.delete_doc("city", city_name, ignore_permissions=True)

This will allow the deletion of the city even if the user doesn’t have the necessary rights.

Thank You!

Thanks For reply NCP,
Using this, the data in the doctype was not deleted

Hi @Priyank_Suthar,

I tried it and it works on my end. Please double-check and give it a try again:

frappe.delete_doc("city", city_name, ignore_permissions=True)

Thank You!

Thanks @NCP ,
Problem was resolved.