為什麼明明在 Profile/Permission Set 開了 delete 的權限,仍然沒有權限刪除 record ?
問題描述
發現某一個 user 在刪某 custom object 的 record 時,會遇到權限不足的錯誤訊息。
- 在 Profile/Permission 設定,已經把 Create/Read/Update/Delete 的權限全開了。FLS(Field-Level Security)的Read和Edit也全開了。
- 該 object 的 sharing setting 為 Public Read/Write,且Grant Access Using Hierarchies設為TRUE。
原因
即便是 public read/write 的 object,即便你有 delete 這個 object record 的權限。但你仍然不能 delete 那些不屬於你的 record。
只有這三種情形允許 delete record:
- Is the record owner.
- Is higher than the owner in the owner's role hierarchy
- Has the 'Modify All' permission
如果你不屬於以上三種,但又很需要有 delete record 的權限,勉強有一些 workaround:
- 做一個 custom button ,靠 Apex Class以 system 身份來 delete record。
- 把 record 的 owner 設成該 user 或是他的下屬。
補充說明
為什麼都已經把 user 的 UserRole 設成最高層級 CEO 了,還是會遇到權限不足的情況呢?
因為你可能遇到 owned by another CEO 的 record了😆
你只能刪你下屬的,不能刪你平行同事的。
合理。
留言
張貼留言