Skip to Content

IDM 8 RuntimeException - undefined: undefined is not a function

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Sep 04 at 11:40 AM

    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/9405d69708cf41d9b2c574146c585b27.html

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 04 at 11:50 AM

    Hi Richard,

    try

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

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

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 06 at 07:48 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.