Skip to main content

Hi everyone!

 

I have this code in js

 

function fDiaLaborable (dFecha){

var dia2 = 1

var mes = dFecha.getMonth();

var anio = dFecha.getFullYear();

var fecha = new Date (anio, mes, dia2)

var dia = fecha.getDay();

if(dia === 6 ){

 dia2 = dia2+2;

}

mes = mes+1;

var resultado = dia2+"/"+mes+"/"+anio;

return resultado;

}

It works in Chrome console, but when i'm trying to execute this in A360 doesn't work, I print a message box and says "bot error" I don't have idea what happens, could you help me?

 

There is my configuration

 

image image2

Hi @Erika Jaramillo​ ,

 

I'll try to look into the JS, but could you check and see whether the date automation that you are performing with JS can be achieved through A360 Actions?

 

There is a DateTime Package which can help you with that, so try using that before using scripts.

When we develop automations as RPA developers, the next person tasked with handling your Automation may or may not know how to work with JS so its better to use Inbuilt Actions wherever we can.

 

Kind Regards,

Ashwin A.K


2022-08-19_22h06_33the parameter passed to JS function is not Date object but a string

it should be converted to Date object then it could have method getMonth()

 

function fDiaLaborable (dFecha){

var dateObj = new Date(dFecha); // add this line.

var dia2 = 1;

var mes = dateObj.getMonth();

var anio = dateObj.getFullYear();

var fecha = new Date (anio, mes, dia2)

var dia = fecha.getDay();

if(dia === 6 ){

 dia2 = dia2+2;

}

mes = mes+1;

var resultado = dia2+"/"+mes+"/"+anio;

return resultado;

}

 

 

and the date string format should in specific format.

 


Thanks! That solves it all, I only have one additional question I'm use this format for the date 31/08/2022, and I send this parameter, the script output send this 1/Nan/Nan, how could I solve?


Reply