Salesforce 之 Knowledge Object 之 mass update published article
最近為了一項關於 Knowledge 的任務感到傷腦筋,是關於要一次更新數萬篇 article 的任務。 背景說明 Salesforce 裡面的 Knowledge ,是一個特別的模組。有著特別的功能……以及一些特別的限制。隨便講幾個出來,背後可能都藏了無數人踩過的坑。(詳細內容可見文末之參考資料) 光看他的 object API name,既不像一般 custom object 一樣有著「__c」的後綴,也不像 standard object 一樣的乾淨俐落毫無後綴。而是帶著一個「__kav」的後綴。光這一點就獨步於全 org 了。 而此次我要做的 patch 任務,如果以其它 object 的概念來說,就是一次 update 數萬筆 record 而已。不管是要用 data loader,或是用 workbench,甚或是寫一支 Apex Code 去跑個 update,都不是什麼困難的事。 但對於 Knowledge 來說,可說是無比的麻煩。 因為已經 publish 的 article 是不容編輯的。 When an article is published, the PublishStatus field on the KnowledgeArticleVersion object is changed from “Draft” to Online. If an attempt is made to update a published article via API, a message will be received indicating that only Draft articles can be updated. ( https://help.salesforce.com/s/articleView?id=000333316&type=1 ) 若以手動更新 article 的方式來說,就是要做這些步驟 Edit the article as a draft。先把已經 publish 的 article 弄成 draft 的狀態。 Update the fields。把你要更新的值填入 article 上的欄位並 save。 Publish the artilce。把你新編輯好的 article publ...