Confused on passing work items from producer to consumer

I have a list of dictionaries that is created by my producer.robot.
I want to pass each dictionary to the consumer.robot to be processed individually.

Work items are really tripping me up here.

Here is my code for separating my list into work items:


One of my work items looks like this:

{‘workorder_id’: ‘34259’, ‘street’: ‘Test Street’, ‘city’: ‘Test City’, ‘state’: ‘TestState’, ‘zip’: ‘55555’, ‘event_type’: ‘Multi-day Travel’, ‘event_subtype’: ‘Multiple Jobs Travel’, ‘start_date’: ‘02/06/2023’, ‘end_date’: ‘02/17/2023’, ‘event_duration’: ‘=K2-J2’, ‘event_workorder_numbers’: ‘34178, 34180, 34182, 34189, 34199, 34200, 34201, 34202, 34203, 34204, 34206, 34208, 34209, 34210, 34211, 34212, 34213, 34218, 34219, 34221, 34222, 34223, 34224, 34225, 34226, 34229, 34230, 34232, 34233, 34234, 34235, 34236, 34237, 34238, 34255, 34248, 34256, 34257, 34258, 34259, 34260’}

Can someone explain to me like I’m dumb what tasks I should use to process each work item individually in the consumer locally.

Create Output Work Item seems like the first step to include in the producer but I can’t wrap my head around how work items are stored dynamically to be processed each time by the consumer.

I am familiar with the Dispatcher Performer in UiPath which is the exact same concept, I just am having trouble figuring out how to put this into practice.

For instance, if I wanted to log the workorder_id of a current work item in the consumer.robot, how would that be done?

Your producer loop looks good, but you may have to add save=TRUE so that output work items are stored.

    FOR    ${item}    IN    @{final_dispatcher_list}
        Create Output Work Item  ${item}  save=True

In production those output work items are stored in Control Room and they are automatically given as input work items for the next step in the same process. If you just run it locally in VSCode (e.g. testing during development) then VSCode handles the work items locally and Control Room is not involved.
In your consumer you can do something like this:

*** Settings ***
Library     RPA.Robocorp.WorkItems

*** Tasks ***
Consume items
    For Each Input Work Item    Handle item

*** Keywords ***
Handle item
    ${item}=    Get Work Item Variables
    Log  ${item}[workorder_id]
    Release Input Work Item    DONE

I have left out all error handling etc, but in this example Handle Item keyword is automatically called once for each work item that you created in producer.

Did this answer your question?

1 Like

I guess my only confusion then is that the logic only processes the last work item unless if before I run the bot, I select an input from the previous run:

Is there no way for it to automatically process the work items from the producer in the consumer in the same run.

Basically, how can I while select “No work item as input” from the dropdown and all of the work items get processed?

VSCode is a development environment that supports the debugging of your code one step at a time. You can first concentrate on implementing the first step and verify the data from the output work items. Then you can move to the second step and develop that with known input data. You cannot test the whole process (multiple steps) in one run in VSCode. You can only run individual steps.
When your development is done, you upload your code (robot) to the Control Room and configure a process with two steps. Then it will automatically run as a whole and all output work items generated in the first step will automatically be transferred as input work items to the second step.

Thank you for clarifying that!