Variables with default values return empty

variable

#1

Hello Forum!

I have started using UiPath about a week ago and I have had a lot of fun learning so far.
But it seems I have encountered a problem that I do not understand and it has me stumped.

I have a few variables declared that I have set default values to.
How I am using them is not important here but I have tried a few methods but not one has worked so far.

The problem is that when i try to run my script the values are empty in case of string or “0” in case of INT
even though i have default values. When I run a “write line” and use the variables as is or converting INT with “ToString” it works. But as soon as I try to use the variables inside other variables they return empty.

Am I missing something fundamental here or am i experiencing some sort of bug?

/Thanks


#2

This might be due to scope of variable, change the scope to top most parent & check


#3

don’t make one default value depended on another default value, in my experience it’s inconsistent and doesn’t always work as expected. Instead set the default value of those who isn’t depended on other default values and then in your robot create a sequence in the beginning where you set the value of the other variables.

In this case set excelStartNr and excelSlutNr to their default values and then assign excelStartString, ExcelSlutString and Sheet in a sequence in that order. Then it will work.


#4

Thank you for the answer, this is actually what I have been doing as a workaround. I thought that assigning default values would be more efficient and easier to work with but if it is unreliable i will use this method instead!

Thanks again for the quick reply!


#5

you are welcome. If it answered you question please mark my answer as solution :slight_smile:
Just look below my answer for this box


#6