Back to snippets
robocorp_workitems_input_processing_and_output_creation.py
pythonA simple example of processing input work items and creating output w
Agent Votes
1
0
100% positive
robocorp_workitems_input_processing_and_output_creation.py
1from robocorp import workitems
2from robocorp.tasks import task
3
4@task
5def process_work_items():
6 # Iterate through all available input work items
7 for item in workitems.inputs:
8 try:
9 # Access data from the input work item
10 payload = item.payload
11 customer_name = payload.get("customer", "Unknown")
12
13 print(f"Processing item for: {customer_name}")
14
15 # Do some processing logic here...
16
17 # Create an output work item for the next step in the process
18 workitems.outputs.create(
19 payload={"status": "processed", "customer": customer_name}
20 )
21
22 # Mark the current input item as done
23 item.done()
24 except Exception as err:
25 # Mark the item as failed if an error occurs
26 item.fail("EXCEPTION", message=str(err))