How to add default values for variables?

I have a scenario where I need to find all the files with a particular ID inside a folder and upload them online. So I am trying to use a variable with an array data type and filling it with default values and if UiPath encounters any of those default values, it must replace it with the file name and upload it. So, can anyone help me in achieving this task?

Also, I get an error stating that (the values may be inaccessible due to its protection level).

Hi @vivek_Chowdary,

The error states that the variable is declared twice or it is declared as local variable. Can you please add a screenshot or your project file if possible?

I have declared the vb expression as follows. Now after ‘empID’, I need to dynamically add the default values of months from the variable.

The screenshot for the variable is as follows:

Try this :
assign activity, declare count variable and initialize to 0

and in the loop, increase the count variable by 1 using assign activity

         "Path " + empID + month(count).ToString + ".pdf"

Hope it helps

1 Like

if you are looking for current month , you can use this .

After empId+ “_”+datetime.Now.ToString(“MMMM”)+“.pdf”

output will be “yourfilename_Month”

Thanks for your help, it worked fine.

But, I also have an year field after month which is not working out when I use the same technique. An error is displayed as follows:

I created an year variable as follows:

The error is year array has only one attribute. So, it will get the value of year(0) and for the second loop, if the code tries to fetch year(1), no second attribute available. So, it is erroring. Try giving year(0) as it is containing only one.

1 Like

yeah yeah got it.
Thank you.:slightly_smiling_face:

Hello, I have a container in a website where I need to upload documents into each and every document separately. So in order to do that what is the vb.net expression that can be used in order to traverse a loop for all the items inside that container?