List of items save to variables

In my workflow I have created find children-> For each → Get attribute to store all the list of items

In find children I have selected a drop down and it stored the IEnumerable.
After that I have used “for each” in that list of items children Is given. Item is “current item”. Inside the body I have given Input Element as “children” , attribute as aaname and save to = any array of string variable is passed. ( It is initially created in data manager as array of type string initiated.

BC30311 value of type string cannot be converted to string() in UiPath

Can anyone tell what mistake it is?

when interested on all aanames from the found uiElements from findChidren

we can do directly

Assign Activity
arrNames | String Array =
YourFindChildrenOutVar.Select(Function (x) x.Get("aaname").toString.Trim()).toArray

@Ragul_sharma

Give Input element as “current item” You want to save the dropdown data in a list right then choose “Items” .Then save it in a list variable

Hi @Ragul_sharma

FindChildren
Output: children

For Each
TypeArgument: UiElement
Values: children
            Get Attribute
           Input Element: currentItem
       Attribute: aaname
       Output: attributeValue
    Assign
       To: attributeValues
       Value: attributeValues.Add(attributeValue)

Assign Activity:
To: arrayOfAttributes
Value: attributeValues.ToArray()

I’m getting like BC30311 error value of string() cannot be converted to string Showing this error. I have created array of string and name of it is uiconfit which I have given in save to box.

@Ragul_sharma

Can you share the workflow snippet.

Make sure Get attribute output will be of string

image

can anyone tell how to create a list of variable to resolve the error.

@Ragul_sharma

UICONFIG variable should be of datatype string

image

we did:

and if a string list is needed we can do

NamesList | String List=
YourFindChildrenOutVar.Select(Function (x) x.Get("aaname").toString.Trim()).toList

@Ragul_sharma

Check the Below one,ask me if you have any doubts

Variables

Entire sequence snippet below

OutPut

How to compare the two list values and show the output as true is all values are same

@Ragul_sharma
Okay.I will give the code for that
Did you got solved above query with my solution.

@Ragul_sharma

The list1 and list2 are the two lists.
The below results either true or false which is of type boolean variable.

list1.SequenceEqual(list2)

Lets retake it and present the different options

Mission: extract all options from a dropdown

grafik

Option 1 - Using the items attribute


grafik

Option 2 - using Find children and processing the result with LINQ


Postprocessing the myChildren
grafik

Option 3 - using Find children and processing the result with For each


grafik

also we can modify like using innertext as attribute or using
myOption = myOption.Append(myAttributeValue).toList instead of Append Item to List

:warning: FINDSCOPE Adaptions
Usually the OPTION elements are children from the Select element
grafik

In case of any other scenarios we set the FINDSCOPE to
grafik
and can scan for deeper nested elements

Yes I have solved.
Thank you so much

@Ragul_sharma

Please Mark my solution as solved to close the loop

when all values are present and also in the same order:
grafik

when all values are present, but not mandatory in the same order
grafik
we can do:

list1.Intersect(List2).Count And List1.Count = List2.Count

Intersect is deduplicating, so we should be carefully, when duplicated values can occur

Can I use select item to fetch all items in list and store it in a Variable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.