通过使用 Dynamics 365(联机)创建流Create a flow by using Dynamics 365 (online)

通过使用 Dynamics 365 连接器可以创建流,这些流在 Dynamics 365 或其他某个服务中的事件发生时启动,然后将在 Dynamics 365 或其他某个服务中执行某项操作。By using a Dynamics 365 connector, you can create flows that initiate when an event occurs in Dynamics 365, or some other service, which then performs an action in Dynamics 365, or some other service.

在 Microsoft Flow 中,可以在最喜欢的应用和服务之间设置自动化工作流,以便同步文件、获取通知、收集数据等。In Microsoft Flow, you can set up automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more. 有关详细信息,请参阅 Microsoft Flow 入门For more information, see Get started with Microsoft Flow.

重要

若要调用流触发器,与流一起使用的 Dynamics 365 客户参与实体必须启用“更改跟踪”。To invoke a flow trigger, the Dynamics 365 customer engagement entity used with the flow must have Change Tracking enabled. 详细信息:启用更改跟踪以控制数据同步More information: Enable change tracking to control data synchronization

通过模板创建流Create a flow from a template

可以使用许多可用模板之一来创建流,示例如下:You can create a flow using one of the many templates available, such as these examples:

  • 当在 Dynamics 365 中创建对象后,在 SharePoint 中创建一个列表项。When an object is created in Dynamics 365, create a list item in SharePoint.
  • 从 Excel 表创建 Dynamics 365 潜在客户记录。Create Dynamics 365 lead records from an Excel table.
  • 将 Dynamics 365 帐户复制到 Dynamics 365 for Operations 中的客户。Copy Dynamics 365 accounts to customers in Dynamics 365 for Operations.

若要通过模板创建一个流,请执行下列步骤。To create a flow from a template, follow these steps.

  1. 登录到 Microsoft Flow 网站Sign in to the Microsoft Flow website.
  2. 单击或点击“服务”,然后单击或点击“Dynamics 365”。Click or tap Services, and then click or tap Dynamics 365.
  3. 有一些模板可供使用。Several templates are available. 若要开始,请选择所需的模板。To get started, select the template that you want.

从潜在客户创建任务Create a task from a lead

如果模板不适用于你的需求,请从头开始创建流。If a template isn’t available for what you need, create a flow from scratch. 本演练演示了如何每当在 Dynamics 365 中创建潜在客户时在 Dynamics 365 中创建任务。This walkthrough shows you how to create a task in Dynamics 365 whenever a lead is created in Dynamics 365.

  1. 登录到 Microsoft Flow 网站Sign in to the Microsoft Flow website.

  2. 单击或点击“我的流”,然后单击或点击“从空白创建”。Click or tap My flows, and then click or tap Create from blank.

  3. 在流触发器的列表中,单击或点击“Dynamics 365 - 创建记录时”。In the list of flow triggers, click or tap Dynamics 365 - When a record is created.

  4. 如果系统提示,请登录到 Dynamics 365。If prompted, sign in to Dynamics 365.

  5. 在“组织名称”下,选择想要流侦听的 Dynamics 365 实例。Under Organization Name, select the Dynamics 365 instance where you want the flow to listen.

  6. 在“实体名称”下,选择想要侦听的实体,这将充当启动流的触发器。Under Entity Name, select the entity that you want to listen to, which will act as a trigger initiating the flow.

    对于本演练,请选择“潜在客户”。For this walkthrough, select Leads.

    流详细信息

    [重要提醒] 要使流在 Dynamics 365 实体上触发,实体定义应启用“更改跟踪”。[IMPORTANT] In order for the flow to trigger on the Dynamics 365 entity, the entity definition should have Change Tracking enabled. 请参阅启用更改跟踪以控制数据同步See Enable change tracking to control data synchronization

  7. 单击或点击“新建步骤”,然后单击或点击“添加操作”。Click or tap New step, and then click or tap Add an action.

  8. 单击或点击“Dynamics 365 – 创建新记录”。Click or tap Dynamics 365 – Create a new record.

  9. 在“组织名称”下,选择想要流创建记录的 Dynamics 365 实例。Under Organization Name, select the Dynamics 365 instance where you want the flow to create the record. 请注意,它不一定是触发了事件的同一实例。Notice that it doesn’t have to be the same instance where the event is triggered from.

  10. 在“实体名称”下,选择在事件发生时将创建一条记录的实体。Under Entity Name, select the entity that will create a record when the event occurs.

    对于本演练,请选择“任务”。For this walkthrough, select Tasks.

  11. 此时将显示“主题”框。A Subject box appears. 单击或点击它时,将显示动态内容窗格,在其中可以选择以下字段之一。When you click or tap it, a dynamic content pane appears where you can select either of these fields.

    • 姓氏Last Name. 如果选择此字段,潜在客户的姓氏将在创建任务时插入到该任务的“主题”字段。If you select this field, the last name of the lead will be inserted in the Subject field of the task when it's created.
    • 标题Topic. 如果选择此字段,潜在客户的“标题”字段将在创建任务时插入到该任务的“主题”字段。If you select this field, the Topic field for the lead will be inserted in the Subject field of the task when it's created.

    对于本演练,请选择“标题”。For this walkthrough, select Topic.

    为流添加标题

    提示:在动态内容窗格中,单击或点击“查看更多”可显示与实体关联的多个字段。Tip: On the dynamic content pane, click or tap See more to display more fields that are associated with the entity. 例如,还可以使用潜在客户的“公司名称”、“客户”、“说明”或“电子邮件”字段填充该任务的“主题”字段。For example, you can also populate the Subject field of the task with the Company Name, Customer, Description, or Email field of the lead.

  12. 单击或点击“创建流”。Click or tap Create flow.

从 Dynamics 365 任务创建 Wunderlist 任务Create a Wunderlist task from a Dynamics 365 task

本演练演示了如何每当在 Dynamics 365 中创建任务时在 Wunderlist 中创建任务。This walkthrough shows you how to create a task in Wunderlist whenever a task is created in Dynamics 365. Wunderlist 是一种基于 Internet 的服务,可用于创建待办事项列表、添加提醒或跟踪事项。Wunderlist is an Internet-based service that you can use to create to-do lists, add reminders, or track errands.

  1. 登录到 Microsoft Flow 网站Sign in to the Microsoft Flow website.

  2. 单击或点击“我的流”,然后单击或点击“从空白创建”。Click or tap My flows, and then click or tap Create from blank.

  3. 在流触发器的列表中,单击或点击“Dynamics 365 - 创建记录时”。In the list of flow triggers, click or tap Dynamics 365 - When a record is created.

  4. 在“组织名称”下,选择想要流侦听的 Dynamics 365 实例。Under Organization Name, select the Dynamics 365 instance where you want the flow to listen.

  5. 在“实体名称”下,选择想要侦听的实体,这将充当用于启动流的触发器。Under Entity Name, select the entity that you want to listen to, which will act as a trigger to initiate the flow.

    对于本演练,请选择“任务”。For this walkthrough, select Tasks.

  6. 单击或点击“新建步骤”,然后单击或点击“添加操作”。Click or tap New step, and then click or tap Add an action.

  7. 键入“创建任务”,然后单击或点击“Wunderlist – 创建任务”。Type create a task, and then click or tap Wunderlist – Create a task.

  8. 在“列表 ID”下,选择“收件箱”。Under List ID, select inbox.

  9. 在“标题”下,选择动态内容窗格中的“主题”。Under Title, select Subject in the dynamic content pane.

  10. 单击或点击“创建流”。Click or tap Create flow.

基于触发器的逻辑Trigger based logic

触发器(如“创建记录时”、“更新记录时”和“删除记录时”)会在事件发生几分钟后启动流。Triggers like When a record is created, When a record is updated, and When a record is deleted initiate your flow within a few minutes of the event occuring. 在极少数情况下,流可能需要长达 2 小时才能触发。In rare cases, your flow can take up to 2 hours to trigger.

触发器触发时,流会收到一个通知,但流在操作运行时已存在的数据上运行。When the trigger occurs, the flow receives a notification, but the flow runs on data that exists at the time the action runs. 例如,如果在创建新记录时流触发,并在流运行前更新此记录两次,则流仅通过最新数据运行一次。For example, if your flow triggers when a new record is created, and you update the record twice before the flow runs, your flow runs only once with the latest data.

指定高级选项Specify advanced options

向流添加步骤时,可以单击或点击“显示高级选项”来添加筛选器或 Order By 查询,从而控制在流中筛选数据的方式。When you add a step to a flow, you can click or tap Show advanced options to add a filter or order by query that controls how the data is filtered in the flow.

例如,可以使用筛选器查询来仅仅检索活跃的联系人,然后可以按姓氏对其进行排序。For example, you can use a filter query to retrieve only active contacts, and you can order them by last name. 为此,请输入 OData 筛选器查询 statuscode eq 1,然后从动态内容窗格选择“姓氏”。To do this, enter the OData filter query statuscode eq 1 and select Last Name from the dynamic content pane. 有关筛选器和 Order By 查询的详细信息,请参阅 MSDN: $filterMSDN: $orderbyFor more information about filter and order by queries, see MSDN: $filter and MSDN: $orderby.

流的 orderby 查询

使用高级选项时的最佳做法Best practices when using advanced options

向字段添加值时,无论是键入值还是从动态内容窗格中选择值,都必须与字段类型匹配。When you add a value to a field, you must match the field type whether you type a value or select one from the dynamic content pane.

字段类型Field type 如何使用How to use 在哪里可以找到Where to find 名称Name 数据类型Data type
文本字段Text fields 文本字段需要单行文本或作为文本类型字段的动态内容。Text fields require a single line of text or dynamic content that is a text type field. 示例包括“类别”和“子类别”字段。Examples include the Category and Sub-Category fields. 设置 > 自定义 > 自定义系统 > 实体 > 任务 > 字段Settings > Customizations > Customize the System > Entities > Task > Fields 类别category 单行文本Single Line of Text
整数字段Integer fields 某些字段需要整数或作为整数类型字段的动态内容。Some fields require integer or dynamic content that is an integer type field. 示例包括“完成百分比”和“持续时间”。Examples include Percent Complete and Duration. 设置 > 自定义 > 自定义系统 > 实体 > 任务 > 字段Settings > Customizations > Customize the System > Entities > Task > Fields percentcompletepercentcomplete 整数Whole Number
日期字段Date fields 某些字段需要以 mm/dd/yyyy 格式输入的日期或作为日期类型字段的动态内容。Some fields require a date entered in mm/dd/yyyy format or dynamic content that is a date type field. 示例包括“创建日期”、“开始日期”、“实际开始时间”、“上一暂候时间”、“实际结束时间”和“截止日期”。Examples include Created On, Start Date, Actual Start, Last on Hold Time, Actual End, and Due Date. 设置 > 自定义 > 自定义系统 > 实体 > 任务 > 字段Settings > Customizations > Customize the System > Entities > Task > Fields createdoncreatedon 日期和时间Date and Time
需要记录 ID 和查找类型的字段Fields that require both a record ID and lookup type 某些引用另一个实体记录的字段需要记录 ID 和查找类型。Some fields that reference another entity record require both the record ID and the lookup type. 设置 > 自定义 > 自定义系统 > 实体 > 帐户 > 字段Settings > Customizations > Customize the System > Entities > Account > Fields accountidaccountid 主键Primary Key

更多需要记录 ID 和查找类型的字段示例More examples of fields that require both a record ID and lookup type

此处对上一个表进行扩展,提供了更多不使用从动态内容列表中选择的值的字段示例。Expanding on the previous table, here are more examples of fields that don't work with values selected from the dynamic content list. 相反,这些字段需要在 PowerApps 中输入到字段的记录 ID 和查找类型。Instead, these fields require both a record ID and lookup type entered into the fields in PowerApps.

  • 所有者所有者类型Owner and Owner Type.

    • “所有者”字段必须是有效的用户或团队记录 ID。The Owner field must be a valid user or team record ID.
    • “所有者类型”必须是 systemusersteamsThe Owner Type must be either systemusers or teams.
  • 客户客户类型Customer and Customer Type.

    • “客户”字段必须是有效的帐户或联系人记录 ID。The Customer field must be a valid account or contact record ID.
    • “客户类型”必须是 accountscontactsThe Customer Type must be either accounts or contacts.
  • 相关项相关项类型Regarding and Regarding Type.

    • “相关项”字段必须是有效的记录 ID,如帐户或联系人记录 ID。The Regarding field must be a valid record ID, such as an account or contact record ID.
    • “相关项类型”必须是记录的查找类型,如 accountscontactsThe Regarding Type must be the lookup type for the record, such as accounts or contacts.

此示例将与记录 ID 对应的帐户记录添加到任务的“相关项”字段中,从而添加该帐户记录。This example adds an account record that corresponds to the record ID, adding it to the Regarding field of the task.

流 recordId 和类型帐户

此示例还基于用户的记录 ID 将任务分配给特定用户。This example also assigns the task to a specific user based on the user's record ID.

流 recordId 和类型用户

若要查找记录的 ID,请参阅本主题中后面的查找记录 IDTo find a record's ID, see Find the record ID later in this topic.

重要说明:如果字段有“仅限内部使用”的说明,则这些字段不应包含值。Important: Fields shouldn't contain a value if they have a description of "For internal use only." 这些字段包括“遍历的路径”、“其他参数”和“时区规则版本号”。These fields include Traversed path, Additional Parameters, and Time Zone Rule Version Number.

查找记录 IDFind the record's ID

  1. 在 Dynamics 365 Web 应用程序中,打开一个记录,如帐户记录。In the Dynamics 365 web application, open a record, such as an account record.

  2. 在操作工具栏上,单击或点击“弹出” “弹出记录”(或单击或点击“通过电子邮件发送链接”,以将完整的 URL 复制到默认电子邮件程序)。On the actions toolbar, click or tap Pop Out popout record (or click or tap EMAIL A LINK to copy the full URL to your default email program).

    在 Web 浏览器的地址栏中,该 URL 包含 %7b 和 %7d 编码字符之间的记录 ID。In the address bar of the web browser, the URL contains the record ID between the %7b and %7d encoding characters.

    RecordId

流故障排除Troubleshooting a flow

有关组织中的流的问答Flow in your organization Q&A

常见问题Frequently asked questions