cancel
Showing results for 
Search instead for 
Did you mean: 

IDM 8 RuntimeException - undefined: undefined is not a function

richard_pietsch
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member358098
Participant
0 Kudos

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.

https://help.sap.com/viewer/4773a9ae1296411a9d5c24873a8d418c/8.0/en-US/9405d69708cf41d9b2c574146c585...

richard_pietsch
Active Contributor
0 Kudos

simple but nice, thanks!

Answers (2)

Answers (2)

todor_petrov
Contributor
0 Kudos

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.

normann
Advisor
Advisor
0 Kudos

Hi Richard,

try

function getRandomNum(lbound, ubound) { return (Math.floor(Math.random() * (ubound - lbound)) + lbound); }

chars.charAt(getRandomNum(0, chars.length));

Regards