Search code examples
automationrpaautomationanywhere

How to append to a list in Automation Anywhere 10.5?


The list starts empty. Then I want to append an value to it for each iteration in a loop if certain condition is met. I don't see append option in Variable Operation.


Solution

  • You can use string split for this, assuming you know of a delimiter that won't ever be in your list of values. I've used a semi-colon, and $local_joinedList$ starts off empty.

    If (certain condition is met)
        Variable Operation: $local_joinedList$;$local_newValue$ To $local_joinedList$
    End If
    String Operation: Split "$local_joinedList$" with delimiter ";" and assign output to $my-list-variable$
    

    This overwrites $my-list-variable$.

    If you need to append to an existing list, you can do it the same way by using String Join first, append your values to the string, then split it again afterward.

    String Operation: Join elements of "$my-list-variable$" by delimiter ";" and assign output to $local_joinedList$