Loving this program; having an issue though conceptually and have looked for hours on how to do this. I am automating a file download where you have to enter a start and ending date. Start date is always fixed, has to be in 01/01/18 format, however the ending date needs to be today’s date, in that format. Is there not a built in variable that just uses today’s date that I can then use in a ‘type’ command as the value? Not sure if I have to use some code in ‘target’ using ‘storevalue’ to take todays date and assign it to a variable, any help is appreciated, thanks everyone.
In download file name you can not use / caracther you can use -
For today date i use this
{
"Command": "executeScript_Sandbox",
"Target": "var d = new Date();var m = ((d.getMonth()+1)<10) ? \"0\" + (d.getMonth()+1):(d.getMonth()+1);var day=d.getDate()<10 ? \"0\" + d.getDate():d.getDate();return day + \"-\" + m + \"-\" + d.getFullYear();",
"Value": "Date"
},
Sorry, I don’t think I was clear but I do appreciate your response.
There is a text box on a web page, I’m ok using a fixed value of 07/01/18 as an example just using the 'type" command, that is for the text box asking for start date.
The end date needs to be today’s date, I run this script everyday to give a data file from 07/01/18 to today’s date and has to be in MM/DD/YY format.
Is there a way to have the type command simply enter todays date in a field in the MM/DD/YY format?
Thanks again everyone, appreciate your help, have a good weekend.
Yes just Type (or XType if need be) the fixed date and then Type | ${Date}
which is your variable from the code above which will be the today date
https://ui.vision/rpa/docs/selenium-ide/executescript#sandbox
Thanks - it definitely works setting the variable, but the date format comes out like this for today “01-08-2020”, I need it like this “MM/DD/YY”, in essence August 1st needs to be like this “08/01/20”. I’ll try and mess around with the sandbox code, but if anyone has any thoughts I would appreciate it, take care.
Here the solution
{
"Name": "Today_Date_Format",
"CreationDate": "2020-8-1",
"Commands": [
{
"Command": "executeScript_Sandbox",
"Target": "var d= new Date(); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); return m+\"/\"+d.getDate().toString().padStart(2, \"0\")+\"/\"+d.getFullYear().toString().substr(2);",
"Value": "Date"
},
{
"Command": "echo",
"Target": "${Date}",
"Value": ""
}
]
}
Log
[status]
Playing macro Today_Date_Format
[info]
Executing: | executeScript_Sandbox | var d= new Date(); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); return m+"/"+d.getDate().toString().padStart(2, "0")+"/"+d.getFullYear().toString().substr(2); | Date |
[info]
Executing: | echo | ${Date} | |
[echo]
08/01/20
[info]
Macro completed (Runtime 0.75s)
Yep, you just nailed it with those last changes; can’t really thank you enough for your help, I really appreciate it.