How to set download file name base on task run times?

Dear Experts

I have a request to download specific data from SAP and save to a location

The key point is that the name of this downloaded excel file need to be set base on task run times

For example, this process will run 3 times a day and the corresponding downloaded excel file names are as below:

8:30 a.m. — Excel file name: yamada 0515-1.xlsx
12:30 p.m. — Excel file name: yamada 0515-2.xlsx
16:40 p.m. — Excel file name: yamada 0515-3.xlsx

Since the process will close automatically aftre run, how can I set a dynamic file name in relative activities?

PS: 0515 is current date

image

Thank you for your kind advise in advance

Ivan
Regards

Create an integer variable to increment for example intCounter with a default value of 1
Do While intCounter < 3
Assign strFilename = "yamada " & DateTime.Now.ToString(“ddMM”) & “-” & intCounter.ToString & “.xlsx”
File exists activity. - check if strFilename exists
If it exists increment counter by assigning intCounter = intCounter+1
If it does not exist then break the loop

Hi @yangyq10
Since your process is time triggered, create an argument called in_runtime in Main.xaml. Now, in Orchestrator, set different value for different time triggers. For Eg: 8:30 am , set run time value as 1. Use the value while naming the downloaded file.

Filename = "yamada "+DateTime.Now.ToString(“ddMM”)+ “-”+in_runtime.ToString+“.xlsx”

I hope this helps you out.
Happy Automation

@avejr748

Thank you for the quick solution.
Can you help take a look if my below process is correct base on your advise?
On the other hand, after I assign intCounter=inCounter+1, how should I put this new filename into the download column I need to input?

image

image

Regards

@yangyq10 Each time the do while loops, a new value is assigned to strFilename until it finds a filename that does not exist and that filename is always stored to strFilename. So just use strFilename variable to type into the filename field of your save dialog box

Thank you. It works!

1 Like

@Rakshan_A Let me check with my IT mate to see how to make it happen via OC. Thank you for your advise!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.