Variable not defined in current scope

I am using a variable inside of a For Each Excel Row activity in the aaname field of the strict selector (aaname = ‘myvariable’). The purpose of this is to allow for accurate and dynamic targets/anchors when searching IDs that return multiple results, of which the ID searched for is one. Uipath is saying the variable is “not defined in the current scope” even though I defined in the For Each Excel Row activity and the click activity using the variable is inside the same Excel activity. Any ideas or something I’m missing maybe?

Hi @Alex_Dowd,

Can you share a screenshot.



I should note that this is only happening with the Target strict selector; the anchor strict select works fine with a different variable, but neither variable works here.

please check if an appropriiate default value is set for the variable

Check list:
*Remove the unused variable and make sure you are having the proper variable
*Open the UIExplorer and right click on your aaname variable and select the variable as per the below
*And keep log message , That will help you to debug it.

if you still face any issue, Please share the issue screenshot :slight_smile:


This didn’t solve the original issue which is the variable being declared out of scope. UiPath is unable to correctly find the target, presumably because of this, even though i am separately verifying that the variable contains the correct field via message box

This didn’t change anything i’m afraid

better you show us the details as similar in the linked post. So we can better help

Could you please provide your error screenshot here :slight_smile:

Did you get solution for this issue? Facing the same.