RPA.Robocorp.WorkItems
Add given file to work item.
Arguments
Argument | Type | Default value |
---|---|---|
path | null | |
name | None |
param path: | Path to file on disk |
---|---|
param name: | Destination name for file. If not given, current name of local file is used. |
NOTE: Files are not uploaded before work item is saved
Usage
Remove all data and files in the current work item.
Usage
Create a new output work item with optional variables and files.
Arguments
Argument | Type | Default value |
---|---|---|
variables | dict, None | None |
files | str, List[str], None | None |
save | bool | False |
An output work item is always created as a child for an input item, therefore a non-released input is required to be loaded first. All changes to the work item are done locally and are sent to the output queue after the keyword Save Work Item is called only, except when save is True.
param variables: | Optional dictionary with variables to be set into the new output work item. |
---|---|
param files: | Optional list or comma separated paths to files to be included into the new output work item. |
param save: | Automatically call Save Work Item over the newly created output work item. |
returns: | The newly created output work item object. |
Examples
Robot Framework
Python
Run a keyword or function for each work item in the input queue.
Arguments
Argument | Type | Default value |
---|---|---|
keyword_or_func | str, Callable | null |
args | null | |
items_limit | int | 0 |
return_results | bool | True |
kwargs | null |
Automatically collects and returns a list of results, switch return_results to False for avoiding this.
param keyword_or_func: | The RF keyword or Py function you want to map through all the work items |
---|---|
param args: | Variable list of arguments that go into the called keyword/function |
param kwargs: | Variable list of keyword arguments that go into the called keyword/function |
param items_limit: | Limit the queue item retrieval to a certain amount, otherwise all the items are retrieved from the queue until depletion |
param return_results: | Collect and return a list of results given each keyword/function call if truthy |
Usage
OR
Get the currently active work item.
The current work item is used as the target by other keywords in this library.
Keywords Get Input Work Item and Create Output Work Item set the active work item automatically, and return the created instance.
With this keyword the active work item can be retrieved manually.
Usage
Load the next work item from the input queue, and set it as the active work item.
Arguments
Argument | Type | Default value |
---|---|---|
_internal_call | bool | False |
Each time this is called, the previous input work item is released (as DONE) prior to reserving the next one. If the library import argument autoload is truthy (default), this is called automatically when the Robot Framework suite starts.
Get attached file from work item to disk. Returns the absolute path to the created file.
Arguments
Argument | Type | Default value |
---|---|---|
name | null | |
path | None |
param name: | Name of attached file |
---|---|
param path: | Destination path of file. If not given, current working directory is used. |
Usage
Get files attached to work item that match given pattern. Returns a list of absolute paths to the downloaded files.
Arguments
Argument | Type | Default value |
---|---|---|
pattern | null | |
dirname | None |
param pattern: | Filename wildcard pattern |
---|---|
param dirname: | Destination directory, if not given robot root is used |
Usage
Get the full JSON payload for a work item.
NOTE: Most use cases should prefer higher-level keywords.
Usage
Return a single variable value from the work item, or default value if defined and key does not exist.
Arguments
Argument | Type | Default value |
---|---|---|
name | null | |
default |
If key does not exist and default is not defined, raises KeyError.
param name: | Name of variable |
---|---|
param default: | Default value if key does not exist |
Robot Framework Example:
Python Example:
Read all variables from the current work item and return their names and values as a dictionary.
Robot Framework Example:
Python Example:
from RPA.Robocorp.WorkItems import WorkItems wi = WorkItems() wi.get_input_work_item() input_wi = wi.get_work_item_variables() print(input_wi["username"]) print(input_wi["email"])
List the names of files attached to the current work item.
Usage
List the variable names for the current work item.
Usage
Release the lastly retrieved input work item and set its state.
Arguments
Argument | Type | Default value |
---|---|---|
state | State, str | null |
exception_type | Error, str, None | None |
code | str, None | None |
message | str, None | None |
_internal_release | bool | False |
This can be released with DONE or FAILED states. With the FAILED state, an additional exception can be sent to Control Room describing the problem that you encountered by specifying a type and optionally a code and/or message. After this has been called, no more output work items can be created unless a new input work item has been loaded again.
param state: | The status on the last processed input work item |
---|---|
param exception_type: | Error type (BUSINESS, APPLICATION). If this is not specified, then the cloud will assume UNSPECIFIED |
param code: | Optional error code identifying the exception for future filtering, grouping and custom retrying behaviour in the cloud |
param message: | Optional human-friendly error message supplying additional details regarding the sent exception |
Usage
OR
Remove attached file from work item.
Arguments
Argument | Type | Default value |
---|---|---|
name | null | |
missing_ok | True |
param name: | Name of attached file |
---|---|
param missing_ok: | Do not raise exception if file doesn't exist |
NOTE: Files are not deleted before work item is saved
Usage
Removes files attached to work item that match the given pattern.
Arguments
Argument | Type | Default value |
---|---|---|
pattern | null | |
missing_ok | True |
param pattern: | Filename wildcard pattern |
---|---|
param missing_ok: | Do not raise exception if file doesn't exist |
Usage
Save the current data and files in the work item. If not saved, all changes are discarded when the library goes out of scope.
Set the currently active work item.
Arguments
Argument | Type | Default value |
---|---|---|
item | WorkItem | null |
The current work item is used as the target by other keywords in this library.
Keywords Get Input Work Item and Create Output Work Item set the active work item automatically, and return the created instance.
With this keyword the active work item can be set manually.
Robot Framework Example:
Python Example:
Convert all variables in the current work item to Robot Framework task variables, see variable scopes.
Usage
Set the full JSON payload for a work item.
Arguments
Argument | Type | Default value |
---|---|---|
payload | null |
param payload: | Content of payload, must be JSON-serializable |
---|
NOTE: Most use cases should prefer higher-level keywords. Using this keyword may cause errors when getting the payload via the normal Get work item variable and Get work item variables keywords if you do not set the payload to a dict.
Usage
Set a single variable value in the current work item.
Arguments
Argument | Type | Default value |
---|---|---|
name | null | |
value | null |
param name: | Name of variable |
---|---|
param value: | Value of variable |
Robot Framework Example:
Python Example: