把Lookup field轉換成Master-Detail field時,請記得檢查對應的Permission
Summary
If you have granted user an object permission by Permission Set(eg. Read, Edit, etc),
when you convert a lookup field to master-detail field on that object,
the object permission in that Permission Set will be removed automatically if the permission set hasn't grant the Master object permission in advance.
經實驗證實,如果你原本藉由 Permission Set 來授予 user某 object 的權限,
當你把這個 object 上的 lookup field 轉換成 master-detail field 時,原本在 permission set 裡的的這個 object permission 會自動被移除。
除非這個 permission set 原本就有包含 master-detail relationship 裡那個 master object 的權限。
實驗步驟
1. 開一個全新的 permission set ,在其中給予 foo object 的 read 、 edit 權限。並給予對於 foo object 各 field 的 read 、 edit 的 Field - Level Security (FLS)。
2. 把 foo object 裡 lookup 到 bar object 的 field ,轉成 master - detail type
3. 檢視剛剛新開的 permission set ,發現剛給的 object permission 都被清空歸零了。但是FLS都還在。
4. 手動再次把 read 、 edit 等權限勾回來,會發現 permission set 會自動新增 bar object ( master object )的 permission 。(也有可能不會發現,因為他是偷偷自動完成的)
補充說明
雖然Permission Set裡面的 object permission 勾勾被硬生生拿掉了,但是這個行為並不會被記載在 Setup Audit Trail 裡。
會被記載的只有 change field type: The custom field option Master Detail for bar on object foo has changed from off to on
其餘要靠推理得知。
順帶一提
藉由 deploy 到 production 來完成 field type 從 lookup 到 master-detail 的轉換時,單跑 validate (check only) 可能會遇到這個 error: Test only deployment cannot update a field from a Lookup to MasterDetail
此乃正常現象,不必掛懷。等正式按下 deploy 時即可正常。
留言
張貼留言