Skip to content

Download Human Task File

Type: human-task-download-file  ·  Package: Human Task Activities v1.3.3  ·  Output: List<string>

Since: v1.3.0

Brings the files of an answer to your machine: the scanned invoice, the receipt for an advance, the photos of an inspection. When the person answers a task with a form that asks for attachments, the robot only receives each file’s reference in fields ({id, name, …}); with this activity it downloads them to keep working with them (upload them to the ERP, read them with OCR, archive them).

  1. Looks up the taskId task in the environment where the execution runs. The task must be closed (decided, expired or cancelled): if it’s still pending or claimed, the activity fails.
  2. Chooses which files to download:
    • Without field or file: every file in the answer.
    • With field: only the files in that field. For a file column inside a table, use table.column (for example, expenses.receipt); with just table, it brings the files from all its columns.
    • With file: only the ones you specify, as they arrived in fields (a file, a list of files or the id). If you pass file but it’s empty, nothing is downloaded.
  3. Saves them in destination with their original name, sanitized for Windows (no paths or invalid characters). If two files have the same name, the second one becomes name (2).ext. A file that already exists with that name in the folder is replaced.
  4. Returns the list of local paths, in the order they were downloaded.

Only files that are part of that task’s answer are downloaded (not the attachments the robot added when creating it). Every download is recorded in the audit log as a file read by the robot.

ParameterTypeDefaultDescription
taskIdstring—Task id (the id returned by Create Human Task).
destinationstring—Folder where the files are saved (created if missing). If a single file is downloaded and destination has an extension, doesn’t end in \ and isn’t an existing folder, it’s used as the full file path (e.g. C:\out\receipt.pdf).
ParameterTypeDefaultDescription
fieldstring—Key of the form’s file field, or table.column for a column of a table. Empty = every file.
fileobject—A file ({id, …}), a list of them or an id, taken from fields. Set but empty = nothing is downloaded. Can be combined with field.

Returns a List<string> with the full local path of each downloaded file. If the answer has no files (or none in field), or if file was empty, the list is empty: that’s not an error.

MessageCause and fix
'taskId' is required. / 'destination' is required.A required parameter is missing.
The task has no answer yet: wait until it is decided (for example, with «Wait for Human Task»).The task is still pending or claimed. Wait for the decision before downloading.
'file' must be a file from the answer ({ id, name, … }), a list of them or the file id.file doesn’t have a valid shape (for example, a dictionary without id).
File … is not in the task answer. / … (field «…»).You asked in file for a file that isn’t part of that answer, or isn’t in field.
Zoan Cloud did not return the file download link. / The download failed: HTTP ….The download failed. Retry with Retry.
… HTTP 404: … (task not found)The id isn’t valid or the task belongs to another environment.
Human task activities require a Zoan Automation runtime context. Missing: …The process isn’t running from Zoan Cloud or from the Designer signed in.

Communication errors arrive with the prefix “Could not download the task files: ”.

Download the receipts of an advance request that has already been decided and loop over them:

Wait for Human Task taskId = task["id"] → output: result
If condition = result["decision"] == "Approve"
└─ then:
Download Human Task File taskId = task["id"] field = "receipt"
destination = "C:\Advances\" + str(result["id"])
→ output: files
For Each items = files itemVariable = path
└─ activities:
Log level = info message = "Receipt downloaded: " + path

files holds the path of each receipt, ready to loop over with For Each.