Question

Setting the workitem status to failed if an error occurs

  • 3 February 2023
  • 3 replies
  • 180 views

Badge +1

Is it possible to force a workitem to fail in AA360? For example, i have a queue set up that needs to log into a website and perform some tasks, sometimes the bot struggles finding a link on the website and throws and error. I can set the workitem result to “Error - description” but the status of the work item remains complete:

 

 

is there a way we can set this in the bot to a failure and it can be retried?

 

Thanks

Tom


3 replies

Badge +1

Hello, I am replying because I have this same question. We are running tests inside of Try/Catch blocks. None of our tests show a “Failure” due to the Catch block handling the errors even if the tests did actually fail. I would like to know if we can force fail the script within the Catch or Finally blocks so that we can show test run reporting in the History and Bot Insights sections in Automation Anywhere. 

Best practice is to utilize Try/Catch but right now we wont get a Failure if the Catch block handles the error successfully. We definitely still want to see Failures when the Catch block is invoked so that we can investigate and fix the issue faster and have better reporting metrics. 

One other thing I noticed is using the Try/Catch blocks actually make using a cleanup script easier as you know which applications/browsers may be open for a currently running script and you can close them specifically if the test fails. However, if you do not use the cleanup script at the end of the test(In a finally block) then you subsequently have to make a cleanup script at the beginning of each script that will run to try and close any open Browsers/Applications without you knowing what might actually be displayed. There is a lot more ambiguity when running a cleanup script at the beginning of each task bot to be executed. 

Thanks,
Ben

Userlevel 5
Badge +10

@Tom 2382  There is no directway to do this but using api  we can achieve 

 

To update the work item from the queue, we need to follow the Request body syntax shown below.

Instructions

Use the syntax shown below:

{

"id":"<workitemID>",

"version":"<latest number>",

"json":{"<column 1 name>":"<column 1 value>",
"<column 2 name>":"<column 2 value>"},

"result":"sucessfully updated",

"status":"READY_TO_RUN",

"queueId":"<queueid>"

}

Additional Information

Example:

{

"id":"116",

"version":"0",

"json":{"id":"1","name":"AA","age":"29"},

"result":"sucessfully updated",

"status":"ON_HOLD",

"queueId":"6"

}


Workload Management API documentation:

Userlevel 3
Badge +6

Just throw error explicitly from your master bot and it would mark as failed.

Even if you are using try catch, check in catch: This error is unhandled/should fail in queue? Throw error

Reply