Hi @ulrich @Plankton
I need to convert 2 javascript code created with storeEval To executeScript_Sandbox
First storeEval code (return date):
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(); day + “-” + m + “-” + d.getFullYear();
Second storeEval code (return time):
let d = new Date(); let h = d.getHours(); h = h < 10 ? “0” + h : h; let m = d.getMinutes(); m = m < 10 ? “0” + m : m; let s = d.getSeconds(); s = s < 10 ? “0” + s : s; h + “-” + m + “-” + s;
With storeEval working and show Date And Time in a prefered format i need to use it with new executeScript_Sandbox command.
Thanks
Hi @newuserkantu. All you have to do is add return to your last statement. That’s the only difference with excecuteScript_Sandbox. Also confused me at first.
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();
and
let d = new Date(); let h = d.getHours(); h = h < 10 ? “0” + h : h; let m = d.getMinutes(); m = m < 10 ? “0” + m : m; let s = d.getSeconds(); s = s < 10 ? “0” + s : s; return h + “-” + m + “-” + s;
Hi thanks for reply but kantu show me an error with your code
Error in executeScript_Sandbox code: expected expression, got keyword ‘return’
Can you help me to solve this, with storeeval working.
Can you try your code in kantu please ?
Thanks
Any suggestion please ?
The code posted give error.
Thanks for help
The command storeEval is deprecated. Better executescript or executescript_Sandbox. The second “return” is wrong in the post by william19.
{
"Name": "test-date",
"CreationDate": "2019-10-4",
"Commands": [
{
"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": "text1"
},
{
"Command": "executeScript_Sandbox",
"Target": "let d = new Date(); let h = d.getHours(); h = h < 10 ? \"0\" + h : h; let m = d.getMinutes(); m = m < 10 ? \"0\" + m : m; let s = d.getSeconds(); s = s < 10 ? \"0\" + s : s; return h + \"-\" + m + \"-\" + s;",
"Value": "text2"
},
{
"Command": "echo",
"Target": "${text1}",
"Value": ""
},
{
"Command": "echo",
"Target": "${text2}",
"Value": ""
}
]
}
Output:
04-10-2019
00-32-21
2 Likes
Working like a charm, you saved my life
Thanks for help me
Thanks @thecoder2012. I corrected my original post. Sorry @newuserkantu for not getting back, was tied up at work.