發表文章

目前顯示的是有「isUpdateable」標籤的文章

[Apex] List all non-editable fields

When we want to customize a FieldHistory object, such as the Opportunity Field History , we would write a small program to check the modification status of all fields when the Opprotunity record is updated. However, some fields are unnecessary, or even should not be checked. For example, some system fields like CreateDate and IsDeleted. In concept, if a field is not Updateable, there is no need to check it. So how do we confirm if a field is Updateable or not? Here is a ready-made method: (Using Opportunity as an example): Opportunity . sObjectType . getDescribe (). fields . getMap (). get ( fieldName ). getDescribe (). isUpdateable () The plain translation of the above line is roughly as follows: Retrieve the field map of the Opportunity object, and then extract the properties of the specified field from the field map. One of the properties that can be checked is isUpdateable. 

[Apex] 列出所有不可編輯的欄位

當我們想要自己客製化一個 FieldHistory object,例如 Opporutunity Field History,我們就會寫一支小程式,在 Opprotunity reocrd 被更新的時候檢查 所有欄位 的異動狀態。 但其實有些欄位是不必要、甚至是不應該檢查的。 例如某些系統欄位:CreateDate、IsDeleted 之類的。 概念上來說,如果某個 field 不是 Updateable,就毋須檢查。 那如何確認某個 field 是不是 Updateable呢? 這裡有一個現成的方法可用: 以 Opportunity 為例: Opportunity . sObjectType . getDescribe (). fields . getMap (). get ( fieldName ). getDescribe (). isUpdateable () 上面這行的白話翻譯大致是∶把 Opportunity 這個 object 的 field map 抓出來之後,再從 field map 裡面提取指定 field 的屬性,其中一個可以檢查屬性就是 isUpdateable。