發表文章

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

[Zapier] How to replace Path action with Code action?

圖片
Issue I want to send notification emails to different product teams using Zapier. The team to send the email to is determined based on a multiple picklist value on a Salesforce Account, which may contain multiple different products. The intuitive solution is to use a "path" with an IF-ELSE function. However, there are a few problems: The path must be placed at the end of the entire Zap. This means that you cannot first check the first product and then sequentially check the second and third products. If you want to use Zapier's path function to implement a conditional action, you need to upgrade to a Professional version or higher, which requires additional cost. (Ref:  https://zapier.com/app/pricing ) In short, path cost money, and I don't have money. Solution Fortunately, Zapier offers a powerful tool called "Code," where you can use JavaScript or Python to do a lot of things you want. (Code Tool: https://zapier.com/apps/code/integrations ) Assuming tha...

[Zapier] 從 Salesforce 觸發 Zapier 的寄信動作,但邏輯稍微複雜,我又沒有錢升級 Zapier 到 Professional 版本,該怎麼辦?

圖片
問題 我要利用 Zapier 發通知信給不同的 product team。至於要發給哪個 team 則是根據 Salesforce Account 上的某個 multiple picklist value 來判斷,裡面可能同時含有多種不同的 product。 直覺簡單的想法就是使用類似 IF-ELSE 功能的 "path"。 但遇到了幾個問題: path 一定要擺在整個 zap 的最後一步。意即你無法先判斷完第一個 product 再依序判斷第二個第三個。 若要使用 Zapier 的 path 功能來實現 conditional action 的話,就必須付更多的錢升級到 Professional 版本以上才行。 (Ref:  https://zapier.com/app/pricing ) 簡單來說,path 要錢,而我沒有錢。 解決方案 還好 Zapier 提供了一個極為強大的工具是 "Code",你可以在其中用 JavaScript 或是 Python 做到一大堆你想做的事情。 (Code Tool: https://zapier.com/apps/code/integrations ) 假設我有五種可能的 product ,我原本直覺的設計是要放五個不同的寄信 action,每個產品的 action 有各自不同的 subject, body, recipients。並在這五個 action 上加上條件判斷,各自判斷要不要執行。 一旦論及條件判斷,在不寫 code 的情況下,就一定得使用 path。 不過還好,我們可以寫 code! 我把五個寄信 action 合併成一個,裡頭的 subject, body, recipients 全都設成變數。 哪裡來的變數呢? 是在前一個步驟用 python 產生出來的! 只要先用 ptyhon code 把所有要用到的參數都準備好,就可以使用 for loop 去對每個 product 各執行一次寄信的 action。 以此省下了每個月數十元美金。 概念很簡單,附上一個簡單的 sample: product_list = input_data[ 'products_str' ].split( ";" ) product_config = []...

如何下載Event Log File / How to Download EventLogFile

 這一篇會用三言兩語簡述一下Event Log File的概念,然後列一些 document 及resource 供參。 重點提要 Salesforce 有一個 object 叫做 EventLogFile。存放著 Event Log File 的 record SOQL sample:  SELECT EventType,Id,LogDate FROM EventLogFile 注意:這裡存的是 Log File 的 record,並不是 Log 本身。如果想要細看 Log ,需要把 Log File 下載下來。 依照你付給 Salesforce 的費用多寡,能查看的歷史 Log 範圍也有所不同。從一天到三十天不等。 The event types you can access and how long the files remain available depends on your Salesforce edition. - Developer Edition organizations have free access to all log types with 1-day data retention. - Enterprise, Unlimited, and Performance Edition organizations have free access to the insecure external assets, login, logout, and total API usage event log files with 1-day data retention. For an extra cost, you can access all log file types with 30-day data retention. 不同類型的 Log 會分門別類存放,可用 EventType 做篩選。有約50種 EventType。在此列出常用的幾種: ApexExecution ApexTrigger KnowledgeArticleView LightningPageView PackageInstall Report ReportExport Search VisualforceRequest Log File 下載方式...