Skip to main content
Solved

Obtaining a work item ID from a queue


Forum|alt.badge.img+17

I have been looking at the WLM APIs, and saw an endpoint for updating a work item in a queue. Started looking into it, with a couple of potential use cases in mind, but there seems to be no easy way to get the workitem ID; am I incorrect in this? The v3 WLM endpoint has a GET workitem call, but you have to already have an ID in order to use it.

 

I am trying to find out if I am just missing something stupid simple, or if this truly is not possible through either a bot (doesn’t appear to be part of the $workitem$ var, or the API. And if it is not possible, what is the point of a PUT to update a workitem without a GET to obtain one??

 

Also, I did do a search on the forum, and see this questions asked several times over the years, but no answers yet.

Best answer by JLogan3o13

@DK 964 The problem statement is I want to obtain the ID of the current workitem being processed, without having to do the following (which is how I would have to do it today):

  • Call the WLM v3/queues/list endpoint, filtered by name to get the appropriate queue ID

 

  • Call the WLM v3/queues/workitems/list endpoint, passing the queue ID, to obtain a list of queue items. Filter to find the workitem I am after.

 

  • Call the WLM v4/queues/<ID>/workitems/<ID> endpoint to update the appropriate work item after locating it
    • ​​​​​​​Or, obtain Queue Name (not ID) and use the Update Work Item Action once I have the workitem ID.

 

  • Call the WLM v3/queues/<ID>/workitems/<ID> endpoint to confirm the update is made per requirements

My thought being, the bot already interacts with the queue item in the background when it pulls it in, meaning it has access to the ID. I just need to find a way to expose that ID outside the above 4-Step process. I wanted to confirm I was not missing something simple, and that this is actually the only way to do this today. I have submitted a Feature Request to see if we can get the ID exposed as part of the $workitem$ record when it is pulled in.

View original
Did this topic help answer your question?

5 replies

Dineshkumar Muthu
Navigator | Tier 3
Forum|alt.badge.img+9

@JLogan3o13 

The latest Workload package includes an option to update the workitems.

You will need to use a loop to retrieve and process the workitems.


Oli.Morris
Automation Anywhere Team
Forum|alt.badge.img+8
  • Automation Anywhere Team
  • 22 replies
  • February 11, 2025

@JLogan3o13

This can also be done via the APIs.

1. List work items

POST {{ControlRoomURL}}v3/wlm/queues/37/workitems/list

Body:

//https://community.cloud.automationanywhere.digital/swagger/ui/?url=/swagger/api/v3/wlm-api-supported.yaml#/
{
    "sort": [
    {
        "field": "updatedOn", // set sort by criteria
        "direction": "desc"
    }
    ],
    "filter": {
        "operator": "and",
        "operands": [
            {
                "operator": "eq",
                "field": "status",
                "value": "COMPLETED"
            },
            {
                "operator": "ge",
                "field": "createdOn",
                "value": "2022-04-04T00:00:00.485024Z"
            }
        ]
    },
    "page": { //return a limited number of results with offset for pagination
        "offset": 0,
        // "total": 0,
        // "totalFilter": 0,
        "length": 5
    }
}

If you’re testing this out in Postman you can use the following script to get the workitem_id:

var jsonData = JSON.parse(responseBody);

if (jsonData.list && Array.isArray(jsonData.list)) {
    var ids = jsonData.list.map(function(item) {
        return item.id;
    });

    console.log(ids);

    pm.environment.set('workitem_ids', ids);
} else {
    console.warn('The "list" property is not an array or is undefined.');
}

Of course you’d need to replicate this logic in an API task or Bot.

2. Update work items

PUT {{ControlRoomURL}}v3/wlm/queues/37/workitems/206779

Body:

{
    "id": 206779,
    "queueId": 37,
    "status": "ON_HOLD",
    "deferredUntil": "2025-05-01T08:00:00.663681Z",
    "json": {
        "Order-ID": "ABC_123",
        "Stage": "2",
        "Description": "100"
    }
}

 


Forum|alt.badge.img+17
  • Author
  • Navigator | Tier 3
  • 83 replies
  • February 11, 2025
DK 964 wrote:

@JLogan3o13 

The latest Workload package includes an option to update the workitems.

You will need to use a loop to retrieve and process the workitems.

I may not have been clear enough in my original post. I am looking to grab only the current workitem ID. Some queues have thousands of items being processed by multiple bot runners, and to loop through 5500 entries every run would be unmanageable. Not to mention the loop through workload items only allows me to loop through a max of 1001 items, with no inherent option to do any filtering (beyond status) to ensure the one I am after is in the returned group.


Dineshkumar Muthu
Navigator | Tier 3
Forum|alt.badge.img+9

@JLogan3o13 , What is your problem statement, can you explain more?


Forum|alt.badge.img+17
  • Author
  • Navigator | Tier 3
  • 83 replies
  • Answer
  • February 18, 2025

@DK 964 The problem statement is I want to obtain the ID of the current workitem being processed, without having to do the following (which is how I would have to do it today):

  • Call the WLM v3/queues/list endpoint, filtered by name to get the appropriate queue ID

 

  • Call the WLM v3/queues/workitems/list endpoint, passing the queue ID, to obtain a list of queue items. Filter to find the workitem I am after.

 

  • Call the WLM v4/queues/<ID>/workitems/<ID> endpoint to update the appropriate work item after locating it
    • ​​​​​​​Or, obtain Queue Name (not ID) and use the Update Work Item Action once I have the workitem ID.

 

  • Call the WLM v3/queues/<ID>/workitems/<ID> endpoint to confirm the update is made per requirements

My thought being, the bot already interacts with the queue item in the background when it pulls it in, meaning it has access to the ID. I just need to find a way to expose that ID outside the above 4-Step process. I wanted to confirm I was not missing something simple, and that this is actually the only way to do this today. I have submitted a Feature Request to see if we can get the ID exposed as part of the $workitem$ record when it is pulled in.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings