Assignment 2 uipath level 3 - monthly report download

Hi,
My query may be too simple but I am stuck and my mind is no more working.
I am assigning ReportFilePath=path.Combine(Environment.CurrentDirectory, in_MonthlyReportsDownloadPath, “Report-”+in_TaxID+"-"+in_Year+"-"+month.ToString+".csv")
and so it is generating file as “C:\Users\HP1\Documents\UiPath\UiPath_REFrameWork_GenerateYearlyReport\ReFrameWork_GenerateYearlyReport_Performer\Data\Temp\Report-RO254678-2017-January.csv”
which technically is correct as Months is an array of string type, where month is an individual array item.
But the problem is I want the report to be saved as “Report-RO254678-2017-1.csv” and not Report-RO254678-2017-January.csv"
How to get “1” from the string array with “January”? Pls help.

1 Like

monthInDigit = DateTime.ParseExact(month, “MMM”, CultureInfo.InvariantCulture).Month;

This will return you integer
Then you can save mothInDigit as string

1 Like

@Aishwarya28

by default the report will be saved as “Report-RO254678-2017-1.csv” right…?

thanks

Not exactly, you pass the value of the Month sy, January in the month part and it will give you 1.
So if you use that whole below in the file naming part

Here
ReportFilePath=path.Combine(Environment.CurrentDirectory, in_MonthlyReportsDownloadPath, “Report-”+in_TaxID+"-"+in_Year+"-"+month.ToString+".csv")

You will get your required result.
So yo will use:

ReportFilePath=path.Combine(Environment.CurrentDirectory, in_MonthlyReportsDownloadPath, “Report-”+in_TaxID+"-"+in_Year+"-"+DateTime.ParseExact(month, “MMM”, CultureInfo.InvariantCulture).Month+".csv")

2 Likes

Hi @Aishwarya28

In the type into activity, try unchecking the simulate type and instead of clicking on the save button try using the enter short key.
So the value will look like this: ReportFilePath+ “[k(enter)]”

instead of month , you can pass array index. set a counter variable to 1.
for each month in Months
select month from dropdown
click download
verify if report exists
on save (Environment.CurrentDirectory, in_MonthlyReportsDownloadPath, “Report-”+in_TaxID+"-"+in_Year+"-"+counter.ToString+".csv")

increment count -make sure increment operation is outside if
counter=counter+1

let me know if this helps

1 Like

I am getting error in "System1_CreateYearlyReport.xaml’ while assigning the value to Variable “ReportFilePath”
The value I have tried so far are as below -

  1. path.Combine(Environment.CurrentDirectory, in_ReportDownloadPath,“Report-” +in_TaxID+ “-” +in_Year+ “-” +month.ToString+ “.csv”)

  2. path.Combine(Environment.CurrentDirectory, in_ReportDownloadPath,“Report-” +in_TaxID.ToString+ “-” +in_Year.ToString+ “-” +month.ToString+ “.csv”)

  3. path.Combine(Environment.CurrentDirectory, in_ReportDownloadPath,“Report-” +in_TaxID.ToString()+ “-” +in_Year.ToString()+ “-” +month.ToString()+ “.csv”)

  4. path.Combine(Environment.CurrentDirectory, in_ReportDownloadPath,“Report-” +in_TaxID+ “-” +in_Year+ “-” +month+ “.csv”)

Fourth option gives ‘validation’ error and is getting fixed if I add +month.ToString+

Otherwise the error message is similar every time. Following is the error -

Activity Name Assign
Message Value cannot be null
parameter name: path2
Global Exception Handler N/A

“in_ReportDownloadPath” Argument is created as “String”.

Please help!

Hi Anurag,

I have used below:

path.Combine(Environment.CurrentDirectory, in_MonthlyReportsDownloadPath, extra(7))

Please see attached. IT will explain what all steps I have used. DO let me know in case of any confusion.

Thanks & Regards,

Aishwarya Gupta

1 Like