Skip to main content

Hi,

 

I have a list of dictionaries, when I want to remove an item using the component List: Remove item I get this error :

class com.automationanywhere.botcommand.data.impl.DictionaryValue cannot be cast to class com.automationanywhere.botcommand.data.impl.ListValue (com.automationanywhere.botcommand.data.impl.DictionaryValue and com.automationanywhere.botcommand.data.impl.ListValue are in unnamed module of loader java.net.URLClassLoader @76452e33)

 

Do you know what can be the cause of this error ? How can you remove the dictionary element from a list ?

Here is a sample bot showing the error

 


It appears it cannot do this. What are you intending on using this for? I see some test code, but do you have a real-world application for this? Maybe if I knew that I could recommend a different way to attack the problem.

You can also consider using a data table to hold a running “list” of data. It’s going to be more manageable than dealing with Dictionaries embedded in a list.

If you do need this functionality, I would recommend putting in an enhancement request or contacting your CSM to do the same.


Hi, The error occurs because the List: Remove Item action requires the output variable to match the type of items in the list for storing the removed item.

If the list contains dictionaries, the output variable must be of type Dictionary or Any. A type mismatch occurs if it is assigned to a List. To resolve this issue, set the output variable to Dictionary or Any.

Please mark the response as a solution if it helps you.


It appears it cannot do this. What are you intending on using this for? I see some test code, but do you have a real-world application for this? Maybe if I knew that I could recommend a different way to attack the problem.

I have found a workaround on my side, but thanks a lot :)

I have a list of items, the dictionary has the attributes itemCode/serial/price/etc.

Is that a bad practice ?


I don’t think it’s bad practice. Just that I’ve heard from Engineering this isn’t really supported, even though we have actions that return a list with dictionaries inside. I’m glad you found a workaround!


Okay, I understood the error : the “output” variable is not the list, it is the element removed you can keep !

I understood it the wrong way

 


Reply