I have a custom employee field called Misconduct Case Number that’s supposed to be extracted and used elsewhere outside ERPNext. The random string should be in the format [8 Alfanumeric charactors] [Date & Time] [Constant Organization Number] eg DX0FBN78 04200645 PTD0010045
I will appreciate any workaround
function randString(x){
var s = "";
var today = new Date();
var date = String(today.getFullYear()).substring(2, 4)+''+(today.getMonth()+1);
var time = today.getHours() + "" + today.getMinutes();
var dateTime = date+time;
var compNumber = " MSL12001749" ;
while(s.length<x&&x>0){
var r = Math.random();
s+= (r<0.1?Math.floor(r*100):String.fromCharCode(Math.floor(r*26) + (r>0.5?97:65)));
}
return s.toUpperCase() + ' ' + dateTime + compNumber;
}
document.getElementById("foo").value = randString(40);