Trailhead学习:Lightning Flow

Trailhead学习:Data Integration Specialist Superbadge中的Lightning Flow章节。

Choose the Right Automation Tool

这里解析Data Integration Specialist Superbadge中的Lightning Flow章节的’选择正确的自动化工具’(Choose the Right Automation Tool),相关链接如下:

https://trailhead.salesforce.com/content/learn/modules/business_process_automation/process_whichtool

学习

Lightning Flow和Cloud Flow Designer,还有Process Builder有什么区别呢?

  • Lightning Flow 是产品的名字

  • Process Builder 和Cloud Flow Designer 是工具的名字

  • 管理员可以用Process Builder制作Process; 可以用Cloud Flow Designer 制作flows.

利用Process Builder 和Cloud Flow Designer,Lightning Flow可以让你实现如下功能:

  • 使用一个页面创建指导教程或向导。

  • 设置自动化任务(tasks)和流程(process)。使用Process Builder或Cloud Flow Designer可以声明业务流程配置逻辑和操作。 如果需要,可以构建自定义Apex代码以实现相关功能。

  • 连接外部系统

  • 为页面和应用添加自动化功能。

  • 可以不断重用之前所见的Process Builder 和Cloud Flow Designer。在Process Builder中,创建一个可调用的流程(invocable process),以便在其他业务流程中重用该流程的逻辑或操作。在Cloud Flow Designer中,任何flow都可以用作子flow。

题目

题目如下:

1) Which tools are included with the Lightning Flow product?

A:Lightning Experience and Cloud Flow Designer

B:Lightning App Builder and Process Builder

C:Process Builder and Cloud Flow Designer

D:Process Builder, Cloud Flow Designer, and Approvals

解析:题目问的是Lightning Flow产品包含哪些工具?答案是C。

2) Which declarative tool would you use for the following use case? Guide customers through the process of troubleshooting issues with your product.

A) Process Builder

B)Cloud Flow Designer

C)Approvals

D)Apex

解析:哪一个工具可以指导客户完成产品问题排查过程。根据上文功能的第一点,答案是B

3) Which declarative tool would you use for the following use case? When an opportunity’s discount is higher than 40%, notify the CEO via email and request sign-off. Provide a way for the CEO to leave comments.

A) Process Builder

B)Cloud Flow Designer

C)Approvals

D)Apex

解析:如果一个opportunity的折扣是高于40%,需要邮件通知CEO,并且CEO留下意见,很显然,这是通过审批流程实现。所以答案是答案是C

4)Which declarative tool would you use for the following use case? When the Annual Revenue field exceeds $500,000 on an account, automatically update the Customer Priority field to High.

A) Process Builder

B)Cloud Flow Designer

C)Approvals

D)Apex

解析:当客户的年度收入(Annual Revenue)字段超过500,000美元时,系统会知道将“客户优先级”更新为“高”。根据上文的功能2,可以通过Process Builder可以实现这样逻辑。答案是A。之后的文章会通过实例详细学习如何构建Process Builder。

参考

答案链接在此,关于Lightning Flow的答题卡,有需要的话可以参考:

https://quizlet.com/298965518/lightning-flow-flash-cards/


Automate Simple Business Processes with Process Builder

这里解析Data Integration Specialist Superbadge中的Lightning Flow章节的’Process Builder的简单业务逻辑’(Automate Simple Business Processes with Process Builder),相关链接如下

https://trailhead.salesforce.com/content/learn/modules/business_process_automation/process_builder

学习

Process Builder是一个点击式工具,可让您轻松自动化if / then业务流程,并在构建时查看流程的图形表示。

触发器(trigger)识别什么时候进程(process)可以运行。 对于记录更改过程,触发器决定哪个对象以及下面什么情况,该进程(process)要监听相关数据变动:

  • 只有当数据是新建的时候

  • 任何时候数据被新建或者更新。

条件(Criteria):决定是否执行该操作。在此条件,管理员可以设置如下:

  • 设置过滤条件。

  • 输入自定义公式(formula)。 与验证规则(validation rules)一样,公式必须解析为true或false。

  • 选择退出标准并始终执行相关操作。

** 操作(Action) **,开发者可以实现如下操作(不完全举例):

  • 新建数据

  • 更新数据或者其他有关数据

  • 提交审批

  • 发邮件。

*发 Chatter feed.

同时,系统设置了三种Process Types,Process Builder可以自动化几种业务流程。 其主要区别在于生命时候触发触发器(trigger)。

1)Record Change,数据改变

2)Invocable,调用其他Process Builder

3)Platform Event ,平台事件,收到平台事件消息

其中,Lightning Process Builder 相关帮助文档可以参考如下:

https://help.salesforce.com/articleView?id=process_overview.htm&type=5

题目

原题题目如下:

Keep contact addresses in sync with their account’s address

You’ve been given a requirement to keep contact addresses in sync with the accounts they belong to. Use Process Builder to create a process on the Account object that updates child Contact addresses when an account’s address is updated.

Challenge Requirements:

The process can have any name

The process must have an Update Records action that updates Contact mailing address fields (Street, City, State, Postal Code, Country) when the parent Account shipping address field values are updated

The process must be active

解析

题目要求联系人的地址时刻与客户的地址保持一致。具体来说就是当客户的shipping address被更新时候,联系人的mailing address相关字段如Street, City, State, Postal Code, Country)也要被一致更新。

这里我们新建一个Process Builder,名字可以为任意名字。

alt tag

然后设置如下几步流程,

alt tag

1)选择Account 无论是被更新还是新建时候都执行该流程
alt tag
2)系统判定Account是否被新建。
alt tag
3)如果是新建的Account,则新建一个Contact,同时设置相关字段值,令Contact mailing address相关字段等于shipping address相关字段。
alt tag
4)判断Account是否被update,注意条件选择OR
alt tag
5)最后,如果Account是更新的话,会同步更新Contact相关字段
alt tag
最后记得要激活该Process Builder。
alt tag

流(Flow)

本章的主题为Guide Users Through Your Business Processes with Cloud Flow Designer,主要学习流(Flow)的制作方法。

相关链接为:https://trailhead.salesforce.com/content/learn/modules/business_process_automation/flow

题目如下:

Guide users through creating a lead
Build a flow that creates a lead with user-entered information and uploads a related file for the lead. Then add the flow to a Home page.

具体要求如下:
Challenge Requirements:

  • Create a flow:
    • Name: New Lead
    • Type: Screen Flow
  • In the flow, add a screen with these required screen fields.
    • Last Name
    • Company Name
  • In the flow, create a lead record.
    • Use the screen fields to set the lead’s Last Name and Company.
    • Store the lead’s ID in a Text variable called leadId.
  • In the flow, add another screen with a Lightning component screen field.
    • Name the field Upload_File
    • Choose the forceContent:fileUpload Lightning component.
    • Use the leadId variable to set the component’s Related Record ID attribute.
  • Activate the New Lead flow.
  • Create a new Lightning page:
    • Type: Home page
    • Label: Process Automation Home
  • In Process Automation Home, add a Flow component that references the New Lead flow.
  • Activate the page and set it as the default Home page.

题目解析:
题目要求开发者建一个流(Flow),并且输入名字和公司名字,同时实现新建一条Lead的数据。
同时实现上传文档的功能。而相关上传的文档是储存于Lead的附件。最后,用户可以在Home 的页面使用流(Flow)。

首先,在流(Flow)里面先新建一个screen。

image

可以输入名字为screen。
image

同时,加上需要用户输入的两个field:’Last Name’ 和’Company Name’:
image

新建’Record Create’的模块。

image

这里需要新建另外一个变量为’leadId’,是生成新的Lead的时候的Id。也就是下一步需要上传附件时候所对应的leadId。

image

再填加新的上传附件的lightning component。
image

设置上传附件的lightning component的变量。
image

同时,需要设置整个流(Flow)的开始点,点击screen的右上角的绿色按钮。

image

整个流(Flow)份三个模块如下:

image

最后保存整个流(Flow)。
image

保存之后需要激活:
image

之后,需要在Home 的页面加上该流(Flow)。

  • 路径: SETUP–> Lightning App Builder–>New
  • 选择 ‘Home Page’
  • 点击’Next’
  • Label 打上’Process Automation Home’
  • 点击’Finish’
  • 在左边选择’Flow’拖至home页面,

image

就这样,解锁了:
image

Combine the Power of Process Builder and Cloud Flow Designer

接下来的主题是’Combine the Power of Process Builder and Cloud Flow Designer’,讲的是如何将进程生成器(Process Builder)和流(Flow)紧密结合起来。

链接如下: https://trailhead.salesforce.com/content/learn/modules/business_process_automation/business_process_automation_combined

进程生成器(Process Builder)不能解决所有的自动化流程的问题。

  • 发布到社区
  • 提交审批
  • 删除数据
  • 新建一系列数据,并使之相互关联
  • 实施复杂的业务逻辑

管理员或者开发者不必在另一个工具中重建整个业务逻辑。 在流(Flow)中配置更复杂的功能,然后向进程生成器(Process Builder)添加流(Flow)操作。 如果流(Flow)也无法满足您的实际业务需求,您或许可以要求有关开发人员可以编写Apex来执行此操作。 同时通过您的流(Flow)来添加Apex操作。

假如,现在有一个需求是需求是:更新closed won的业务机会(opportunity)。由于closed won的业务机会(opportunity)已经完结,需要复制现有的业务机会(opportunity)。 那么该如何实现呢? 开发人员可以通过进程生成器(Process Builder)复制一个现在已经处于closed won阶段的业务机会(opportunity),但是如果想复制产品(products)并且将其与新的业务机会(opportunity)产生连接。

在进程生成器(Process Builder)中,我们不能获取新建数据的ID,并用于其他用户。但是我们可以在流(Flow)中应用。对于上述的需求,开发人员可以新建一个流(Flow),复制业务机会(opportunity)和其对应的产品(products)。同时新建一个进程生成器(Process Builder)当业务机会(opportunity)时处于closed won阶段,自动调用该流(Flow)。

对于流(Flow)的步骤可以如下:

  • 复制业务机会(opportunity)
  • 复制其对应的产品(products)
  • 连接新建的产品(products)和新建的业务机会(opportunity)
  • 下面来做题目。题目如下:

题目1. An sObject variable can store A)A single value

B)A set of field values for a single record

C)Multiple values of the same data type

D)A set of field values for multiple records that have the same object

解析: 问题是一个sObject可以储存什么。B

题目2. For which use case is it appropriate to combine a process and a flow?

A)Post to an internal Chatter group.

B)Clone a record and its children.

C)Delete a related record.

D)B and C

解析:什么情况需要结合进程生成器(Process Builder)和流(Flow)操作,根据上面的案例,需要复制master-detail的数据,需要用到答案是D。

题目3.Inside a loop, you should avoid:

A)Executing actions, like creating or updating records.

B)Assigning new values to variables.

C)Displaying data to the user.

D)esting another loop.

解析:在一个循环里面,开发者需要避免的是A执行新建或者更新数据的操作。切记,除非开发人员已经确认该循环只执行有限数量次数,任何DML操作都得在循环外面执行。

就这样解锁了。

image

Customize How Records Get Approved with Approvals

本章节讲述的是批准过程(Approval Process)。相关链接如下:

https://trailhead.salesforce.com/en/content/learn/modules/business_process_automation/approvals

挑战如下:

Make sure that prospect amounts are approved before they’re converted to customers

Due to local regulation, new customers must be approved by the legal team. When a user creates an account that has a type of Prospect, they manually submit it for approval by clicking Submit for Approval on the account. The record is evaluated only if its type is Prospect and there are more than 500 employees. When the account enters the approval process, Type gets set to Pending and the record is locked. If approved, Type gets set to Customer and the record is unlocked. If not approved, Type gets set back to Prospect and the record is unlocked.

Before You Start
Verify that the Account object’s Type field has the following picklist values: Prospect, Customer, Pending.

Challenge Requirements:

  • Use the Jump Start Wizard to create a new approval process for the Account object
  • The approval process name must be Approve New Account
  • Pick any email template for approval assignment email template
  • For Entry Criteria, use the following criteria.
    • Account: Type equals Prospect
    • Account: Employees greater than 500
  • For Approver, choose Automatically assign to approver(s) and assign yourself as the approver
  • Click View Approval Process Detail Page and finish off the remaining requirements.
    • In the Initial Submission section, add a Field Update action that updates the Account: Type field to Pending. The name of the action must be Account Type To Pending.
    • In the Final Approval Actions, add a Field Update action that updates the Account: Type field to Customer. The name of the action must be Account Type To Customer.
    • In the Final Approval Actions section, edit the Record Lock action to unlock the record
    • In the Final Rejection Actions section, add a Field Update action that updates the Account: Type field to Prospect. The name of the action must be Account Type To Prospect
  • Activate the approval process

题目解析

题目要求开发者在客户(Account)对象下新建一个批准过程(Approval Process),由于法律的需要,在成为真正客户前需要提交法务部门审批,当审批通过后,该客户(Account)会真正成为客户。

开始前需要确认Account 对象中的Type字段需要有Prospect, Customer, Pending这个三个选项,这三个状态在批准过程(Approval Process)会用到。

在SETUP里面输入Approval Processes,然后找到对应到的Acount对象。选择Jump Start Wizard新建一个批准过程(Approval Process)。
其中,名字必须设置为Approve New Account。项目条件可以设置为(客户: 类型等于Prospect) 和 (客户: 员工大于500)。

image

在“初始提交操作”中,需要添加新的字段更新,将客户: 类型更新为Pending状态。

在“最终批准操作”中,需要添加新的字段更新,将客户: 类型更新为Customer状态,同时在‘记录锁定’中选择“取消锁定可以进行编辑”。

在“最终拒绝操作”中,需要添加新的字段更新,将客户: 类型更新为原有的状态Prospect。

最终流程如下:
image

批准分配电子邮件模板可以任意选择一个。批准人可以设置为自己。

然后点击“启用”按钮,就这样整个批准过程就激活了。然后,我们就这样解锁了Lightning Flow模块:

image

参考

相关参考链接: