订阅

UiPath Data Service

UiPath Data Service 指南

在实体记录中下载文件字段

使用 Studio,您可以轻松操作实体记录的特定文件。这些活动可用于执行各种操作,例如上传、下载或删除实体记录的指定字段的指定文件。

The following example demonstrates how to automatically download from Data Service a specified file containing information from the Olympics games extracted from Wikipedia pages in order to use it for other operations.

前提:在 Data Service 中创建实体

Following the steps detailed in the Creating an Entity page, we created an entity for storing information about the Olympic games.

“奥运会”实体具有以下字段:“名称”(文本)和“徽标”(文件)。
请查看以下页面:

  • the Upload File activity as it contains details about how to use this activity to easily upload the logos;
  • the File page as it provides details on how to upload logos from the platform.

📘

备注:

系统内置字段会自动添加到实体中,以提供有关创建该实体的详细信息。

903903

步骤 1:构建工作流

与查询相关的记录

We use the Query Entity Records activity to pull up a list of records from the Olympics entity from Data Service by setting up the folder variable. This goes through all records from the Name field and outputs them in the olympicsRecords variable to be used in the following Input Dialog activity.

15851585

创建“输入”对话框

Add the Input Dialog activity to display a dialog box containing the Select label message and a Multiple choice Input Type. In the Input array add the olympicsRecords variable created previously for the Query Entity Records activity for which you'll apply the following function: olympicsRecords.Select(Function (o as Olympics) o.Name).ToArray to set up the array of options to choose from.

设置 selectedOlympics 变量,以收集输出结果。

15861586

向文件分配值

使用“分配”活动将先前在“输入对话框”活动中创建的 olympicsRecords.First(Function (o as Olympics) o.Name = selectedOlympics) 变量分配给新的 olympicEdition 变量。

411411

设置“选择文件夹”对话框

Add the Select Folder variable to open a dialog box and create the folder variable for the output folder path. You'll use this variable in the following Download File from Record Field activity.

15881588

从记录字段下载文件

Use the Download File from Record Field activity to download the folder file from the Logo file of the olympicEdition.Id entity record.

15881588

运行“PowerShell”命令

Add the Invoke Power Shell activity to execute the following command line: Path.Combine(folder, olympicEdition.Logo.Name) in order to combine the following input parameters: folder and olympicEditionvariables and the Logo and Name fields created within the Olympics entity.

此活动的用途是调用文件的完整路径,并在默认的照片查看器或编辑器中打开该文件。

15891589

[可选]“注释掉”

As an optional step, we've added an example of how to perform a file deletion which has been commented out to not delete the file at runtime. To do this we added the Comment Out activity. Here we included the following activities that won't be executed at runtime:

请注意,您可以取消注释它来进行试验。

618618
  1. 设置子活动顺序。
    我们添加了一个序列活动,并将其重命名为“已忽略的活动”。
  2. 此处包含“从记录字段删除文件活动,用于从指定的实体记录字段中删除文件。
595595
  1. 为使“从记录字段删除文件活动按预期工作,请按如下所示设置该活动:
    1. 将“记录 ID”设置为在“从记录字段下载文件活动中创建的 olympicEdition.Id 变量。
    2. 要从中删除文件的字段是在本示例开头创建的 Data Service 记录中创建的徽标文件。
    3. 输出记录是在“分配”活动中创建的 olympicEdition 变量。
15881588

完成后,项目应如下所示:

762762

6个月前更新

在实体记录中下载文件字段


建议的编辑仅限用于 API 参考页面

您只能建议对 Markdown 正文内容进行编辑,而不能建议对 API 规范进行编辑。