save_result_file() method

Saves a result file output by a Python/HCL script during a task run.

Syntax

hcl.save_result_file(name = "result_file_name")

Parameters

Name Description
name = result_file_name

The name of the result file. The name must be enclosed by quotation marks.

You must exactly replicate the name of the file that has already been produced by the Python/HCL script, including the file extension.

result_file_name is case sensitive. You must match the case of the file name produced by the Python/HCL script.

Returns

For success, the return code 202. For failure, an error message.

Examples

Save a result file from a task run

You want to save a result file with duplicate invoice records from Q1 2022. The records are contained in a file named Duplicate_Invoices_Q1_2022.csv that you produce using a Python method earlier in a script. To permanently save the file to the Task runs tab in the robot, you need to use the separate HCL method save_result_file().

hcl.save_result_file(name = "Duplicate_Invoices_Q1_2022.csv")

Remarks

File saving behavior

If you save the same result file more than once in the same script the previously saved copy of the file is automatically overwritten.

Visualizing the result file

If you test the save_result_file() method by running a script interactively in the Robots script editor, the result file is saved to the cloud-based Diligent One data storage location. However, the saved result file is not visualized separately from the temporary copy of the file visualized in the Session files panel in the script editor. A 202 return code tells you that a result file has been successfully saved.

If you want to see the saved file visualized separately, create a task and run the script using the task. The saved result file appears in the Task run details panel associated with the specific task run in the Task runs tab.

Script error message

Any of these situations produce the script error message shown below:

  • the specified file has not previously been produced by the script

  • the file name is misspelled

  • the case of the file name is not replicated exactly

  • the file extension is missing

Script error message:

FileNotFoundError: File result_file_name does not exists in the working directory