本文構建Salesforce Lightning Flows 只是一個簡單的實現步驟,原文地址如下:
https://trailhead.salesforce.com/en/content/learn/modules/business_process_automation/flow
在開始之前我們得先知道幾個概念:
- Lightning Flow:它是包含了構建、管理、運行流和流程的產品。
- Flow Builder:它是構建Flow的工具。
- Flow:通過收集數據並在Salesforce org或外部系統中執行某些操作來自動化業務流程的應用程序。
注:then add a flow action to your process。
-
Flow 構建塊
每個Flow都由三個構建塊組成。

-
- Elements:它顯示在畫布上。添加一個元素到畫布,從工具欄單擊或拖拽它。
- Connectors:定義flow在運行時的路徑,它們告訴Flow接下來將做什么。
- Resources:是表示給定值的容器,如字段值或公式。您可以在整個流程中引用資源。例如,查找帳戶的ID,將該ID存儲在一個變量中,然后引用該ID來更新帳戶。
- Flow 元素包含四種不同的類型
- Screen:向用戶顯示數據或從屏幕上收集用戶輸入的信息,可以在屏幕上添加簡單的字段,像輸入字段和單選按鈕,以及out-of-the-box Lightning組件,如文件上傳。
- Logic:控制Flow的數據Create,Update,循環結束設置數據。
- Actions:當您擁有必要的信息(可能通過屏幕從用戶那里收集)時,在Salesforce中執行一些操作。Flow可以查找、創建、更新和刪除Salesforce記錄。他們還可以創建聊天帖子,提交記錄以獲得批准,並發送電子郵件。如果您的操作無法開箱即用,請從Flow中調用Apex代碼。
- Integrations:通過使用核心操作或Apex操作將流連接到外部數據庫。Core actions允許您在不經過Salesforce服務器的情況下發出請求。Flow Builder還與平台事件有一些關聯。使用Create Records元素發布平台事件消息。使用Pause元素訂閱平台事件。
- Screen:向用戶顯示數據或從屏幕上收集用戶輸入的信息,可以在屏幕上添加簡單的字段,像輸入字段和單選按鈕,以及out-of-the-box Lightning組件,如文件上傳。
- Take a Tour(參考)
1.Toolbox:它里面包含元素和資源。
2.Canvas:Flow構建是在可視化界面構建。
3.Button Bar:按鈕提供關於Flow的任何信息,例如:
1、Flow是否被激活
2、Flow保存了多長時間
3、流是否有任何警告或錯誤。要查看警告或錯誤,請單擊相應的圖標
4.Keyboard Shortcuts:使用這些快捷鍵來快速瀏覽Flow
1、windows快捷鍵:
放大,按Ctrl =。
縮小,按Ctrl -。
適應,按Ctrl 0。
縮放以查看,按Ctrl 1。
要平移,按住空格鍵,同時用鼠標拖動畫布。
要選擇畫布上的多個元素,請按住Shift鍵並單擊每個元素。2、Mac 快捷鍵:放大,按Ctrl =。
縮小,按Ctrl -。
適應,按Ctrl 0。
縮放以查看,按Ctrl 1。- 要平移,按住空格鍵,同時用鼠標拖動畫布。
要選擇畫布上的多個元素,請按住Shift或Command並單擊每個元素。
- 要平移,按住空格鍵,同時用鼠標拖動畫布。
-
構建Flow步驟
- 添加一個Screen來收集用戶輸入
- From the toolbox, drag a Screen element onto the canvas.
- Name it New Account in the Label field.
- In Screen Components, click Text and then click Text again.
- Select the first Text screen component and enter Account Name in the Label field.
- Select the second Text screen component and enter Phone Number in the Label field.
- Select the footer and on the right and under Control Navigation, deselect Previous and Pause.
- Click Done.
- 添加Create Record元素來創建記錄
- From the Toolbox, drag a Create Records element onto the canvas. Name it Create Account.
- For How to Set the Record Fields, select Use separate variables, resources, and literal values.
- In Create a Record of This Object, in Object, select Account.
- In Field, select Name.
- In Value, select
- In Store Account ID in Variable, select New Resource from the Variable dropdown. The New Resource window appears.
- In Resource Type, select Variable.
- Name the API Account_Id.
- In Data Type, select Text.
- Click Done.
- In Store Account ID in Variable, select
- Click Done.
- 創建能夠上傳文件的界面
- Drag another Screen element onto the canvas.
- In Screen Properties, configure these settings.
- Name the screen Upload Files in the Label field.
- Under Control Navigation, deselect Previous and Pause.
- If you don't make that selection users will be able to navigate back to the first screen, and multiple accounts could accidentally be created.
- On the left in Screen Components, click File Upload.
- For API Name, enter accountFiles.
- For File Upload Label, enter Upload Related Files.
- For Related Record ID, select
- For Allow Multiple Files, select $GlobalConstant.True.
- Click Done.
- 連接元素以及完成流程
- Click the node at the bottom of Start and drag it to New Account.
- Click the node at the bottom of New Account and drag it to Create Account.
- Click the node at the bottom of Create Account and drag it to Upload Files.
- Save the flow, name it Quick Account in Flow Label, and set the type to Screen Flow.
- Click Save.
Skip the warning you see about Lightning runtime. We talk about that next.
- 讓你的Flows更像Lightning
Salesforce提供了兩種運行時體驗,它們決定了某人在運行Flow的樣子和感覺。讓你的Flows融入到Lightning Experience,確保你在Lightning已啟用了這個Flows。
- From Setup, enter Automation in the Quick Find box, and then select Process Automation Settings.
- Verify that Enable Lightning runtime for flows is selected.
- Save your changes.
-
Distribute Your Flow (分配你的Flow)
- 將Flow分配給用戶。
- 要了解更多關於Flow的分配,請參考Screen Flow Distribution模塊。
- Activate Your Flow(激活你的Flow)
- From Setup, enter Flows in the Quick Find box, then select Flows.
- Click Quick Account.
- Find the appropriate version of the flow, and select Activate in the Action column.
- Add Your Flow to the Home Page(添加你的Flow到Home Page中)
- Create a home page.
- From Setup, enter Builder in the Quick Find checkbox, and then select Lightning App Builder.
- Click New.
- Select Home Page and click Next.
- Give the page a name and click Next.
- Click CLONE SALESFORCE DEFAULT PAGE, select Home Page Default, and click Finish.
- Drag a Flow component to the top of the right column
- For Flow, select Quick Account.
- Save your changes and activate the page. Mark this page as the default home page and click Save.
- To see your flow in action, go to your Home page.
- Click Back to return to Setup.
- Click
, and under All Items, click Home.
- Make Sure Your Users Can Run the Flow
- Create a home page.
- 添加一個Screen來收集用戶輸入