UiPath using assigned value of first iteration for subsequent iterations in For Each Row (Excel Application Scope)

Hi everyone, I’m in a bit of a fix. My issue is quite a complex one and I’ve been stuck with it for 2 days now.

A little backstory, I’m building a tool that takes an ID from an Excel sheet, goes into a website, searches for that ID - based on the ID, the items in the dropdown change dynamically.

So what I’ve done so far is this - Create Excel Application scope, Read range, and did a For Each Row activity. To the logic part of selecting from dropdown based on ID from excel sheet on the website, I used IF Statement something similar to the below:
For privacy reasons, I did not attach the actual build but it’s essentially the same as below (without the animals lol)

The issue now is after completing the first iteration, the value assigned to the variable “item” is being used for subsequent iterations.
For example, for 1st loop: uiPath takes ID “1234” from first row in excel, goes into the browser, enters the ID, dropdown brings back these items; “Rat”, “Cat”, “Fish”. from my if statement above, I’ve specified that “Rat” should always be chosen if “Rat” exists in dropdown items. So our variable item = “Rat”. This runs fine.

Now when uiPath goes into excel to take ID from second row (i.e. second iteration), variable item still remains “Rat”. E.g. if ID from 2nd row is “2345”, dropdown items change in browser and it could be “Cat”, “Dog”, “Fish”.
Logic in nested if statement says choose “Fish” but uiPath does not do that, it tries to find “Rat” from the first iteration instead of dynamically looking for “Fish”. Is there something I’m missing?

I’m not sure I’ve explained this well but I would appreciate all the help I can get. It looks like a minor issue but I just cannot figure it out.

To give you some background on the logic behind the dynamic selection of the dropdown items ; please see this link: Selecting values when dropdown items change based on input value - #11 by mukeshkala

Thanks in advance :slight_smile:

Hey :slightly_smiling_face:

If you 2nd item is not “FISH” then nothing will happen on the second run given your Ifs.

What you want to do is (if I understood it correctly):

  • Use a Switch (in the For Each) with the condition ‘item’. Change to string in type. Then you can do your cases if the formatting is different and you cannot use the same. The default is for you standard.

Then you can simply just use the item in the type/select for your searches.

Hi, for the second row/ID, I mentioned that dropdown items may include “Fish”, “cat”, “Dog”. In the logic above, it should choose Fish if Rat is not among the dropdown items. But it’s still fixated on looking for Rat…
Not sure if that made sense

Can anyone please help with this if you’ve experienced such before… Thanks :slight_smile: