這個欄位明明就存在啊,為什麼一直得到 error message: "Variable does not exist: ContactId"

情境

我在 Opportunity Trigger 裡寫了很簡單的 code,使用到 ContactId 這個 field。

for(Opportunity opp: Trigger.new){
if(opp.ContactId != null){
        // Some actions
}
}

但是要從 VSC deploy 上 sandbox 的時候,被這個 error 給卡住:
Variable does not exist: ContactId  


原因

我這支 trigger 的 API version 太舊了,沒有支援到這個欄位。

解法

把 API version 升級到 46.0 以上即可。





留言

這個網誌中的熱門文章

ISC2 CC (Certified in Cybersecurity Certification) 考試心得

Salesforce證照考試心得 (Administrator and Advanced Administrator)