cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript error: Cannot cast

jaisuryan
Active Contributor
0 Kudos

Hello Experts,

this thread should be in stackoverflow but trying my luck here. Need help on javascript.

I wrote a script as below,

function z_checking_users_assigned(par) {

    var posMSKEY = uGetEntryID();

    var currentIDStore = "%$glb.SAP_MASTER_IDS_ID%";

    uWarning("Position MSKEY: " + posMSKEY);

    var sql = "select mcthismskey from idmv_link_ext2 where mcThisOcName = 'MX_PERSON' and mcothermskey = " + posMSKEY;

    var userMSKEY = uSelect(sql);

    uWarning("userMSKEY from database: " + userMSKEY);

    if (userMSKEY.indexOf("!ERROR") >= 0) {

        uError(userMSKEY);

    } else {

        uWarning("Entering the length check");

        var attributeArray = userMSKEY.split("!!");

        var l = attributeArray.length;

        uWarning("Length of vector is: " + l);

        if (l > 1) {

            uWarning("Length is greater than 1, so setting global variable");

            uSetGlobalVar("POS_MSKEY", posMSKEY);

            var OutString = uRunJobNow(360);

            uWarning("Result of Scheduling: " + OutString);

            uSkip(1);

        }

    }

}

I get attached error.

its executing till uWarning() line. I assume its the condition statement if(l>1) is causing the issue. Please help on this regard.

I tried if(l>parseInt("1",10)

and also var l = parseInt(attributeAray.length,10)

still same error

Kind regards,

Jai

Accepted Solutions (1)

Accepted Solutions (1)

ole_k_rosberg
Explorer
0 Kudos

Hi,

This does not look like an error in the script.

Do you have the text log availabe?

How was the script called? I notice it does not have a return statement.

BR,

Ole K.

Answers (4)

Answers (4)

jaisuryan
Active Contributor
0 Kudos

Hi All,

sorry for the delay, I got drifted away to another issue. I updated the script with return statement and it worked.

The script is an entry script for a task which processes position business role.

Kind regards,

Jai

brandonbollin
Active Participant
0 Kudos

Glad to hear it was a simple answer. 

jaisuryan
Active Contributor
0 Kudos

Thanks all for the help. I will try on Monday and update the post accordingly.

Kind regards,

Jai

brandonbollin
Active Participant
0 Kudos

Looking forward to today's update, Jai! 

former_member201064
Active Participant
0 Kudos

The Class cast execption is really due to the missing return statement. You need to add return par at the end so the pass goes on to the destination tab. Hits me sometimes, too.

This "strange" class cast error occurs because IdM tries to cast nothing to a hashmap which fails.

brandonbollin
Active Participant
0 Kudos

Could the error be that you have no, "else" statement? If I > 1, you execute your block of code but there's no, "else" after that to execute if I <= 1. Even if that else statement just returns nothing, I think you still need to have an else in place. To echo Ole's statement, there is no return statement anywhere in the script. I also believe you need to end with a return of some kind.