on 09-04-2020 11:58 AM
Hi all,
I want to use the following code snippet to generate a tmp random code.
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var len = 20;
var randomCode = Array(len).fill(chars).map(function(x) {
return x[Math.floor(Math.random() * x.length)];
}).join('');
return randomCode;
However, IDM does not accapt this.. message is RuntimeException - undefined: undefined is not a function (in line starting with "var randomCode.."). When I try the code in a browser/editor, it's working without problems...
Ideas?
Regards, RP
Hello.
IdM's Runtime is based on Javascript of 2004, so all new features are not there.
I guess in this case map is causing error. Common advice is to make your javascript code as primitive as possible, without all brand new functions.
Also you could probably make use of uGeneratePassword function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to mention that one of the approved improvements for 2020 for IdM 8 is getting a new JavaScript engine:) Let's hope this one does not drop off.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Richard,
try
function getRandomNum(lbound, ubound) { return (Math.floor(Math.random() * (ubound - lbound)) + lbound); }
chars.charAt(getRandomNum(0, chars.length));
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.