Hi, im looking for an easy way to convert Month name into corresponding digit.
JS would work best i imagine ?
Im using “Data Driven” source of variables, and then i would like to take that and digitize it…
so how do i do that ?
Im terrible with JS
The Variable name is =“Month”, and the value = “October” (but obviously i want it done for all the 12 months)
So i do:
loadVars | data.csv
storeEval | var str=“${Month}”; var res=str.replace(“October”, “10”) | month_digit
this returns
[info] Expand variable ‘var str=“${Month}”; var res=str.replace(“October”, “10”)’ into ‘var str=“October”; var res=str.replace(“October”, “10”)’
im looking for a simple solution, dont even know how to put java into katalon recorder
storeEval references only JS code, how would i write command for it ?
Obviously you need to change how you populate the monthName variable and if you are using full month names then you will need to change the values in monthsArray.
Note that indexOf is case sensitive, so we make sure everything is lowercase.
Also note that JavaScript array indexes are zero-based , so we add 1 to the returned value of indexOf to get the correct number.