@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.
@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"
}
}
@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.
@JLogan3o13 , What is your problem statement, can you explain more?
@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.