@Plankton @ulrich
Below is a sample macro with multiple nested if/elseif/else conditions. Apologies if this is not “cleaned-up” because I had to remove all the variables or links I’ve used on the macro.
Basically we have a variable where we extract the first letter from and from there, I split the ALPHABETS and translated it into IF/ELSE conditions so that the macro will traverse faster.
In my test suite, there are other submacros ran before this one but with the pasted script below, I can recreate the issue. The workaround I implemented here is instead of using IF/ELSE, I used gotoif_v2
and labels
but on some of my processes, this workaround cannot be applied as it will mix up a lot of things on our submacro so I hope there is another workaround for this or a fix if this is a valid issue.
I cannot upload the file as I am a new user here but here is the macro that fails on my end:
[Line 55]: Cannot read property 'find' of undefined
{
"Name": "TestMacro-Failed",
"CreationDate": "2020-11-20",
"Commands": [
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed"
},
{
"Command": "store",
"Target": "12345",
"Value": "DATA"
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${DATA}.toUpperCase()",
"Value": "TEST_VAR_1"
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${TEST_VAR_1} + \"XXX\"",
"Value": "TEST_VAR_2"
},
{
"Command": "executeScript_Sandbox",
"Target": "var getFirstChar = ${TEST_VAR_1}.charAt(0); return getFirstChar.toUpperCase()",
"Value": "TEST_VAR_1_FIRST_CHAR"
},
{
"Command": "comment",
"Target": "***A to F***",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_1_FIRST_CHAR} == 'A' || ${TEST_VAR_1_FIRST_CHAR} == 'B' || ${TEST_VAR_1_FIRST_CHAR} == 'C' || ${TEST_VAR_1_FIRST_CHAR} == 'D' || ${TEST_VAR_1_FIRST_CHAR} == 'E' || ${TEST_VAR_1_FIRST_CHAR} == 'F'",
"Value": ""
},
{
"Command": "comment",
"Target": "***A***",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_2} == 'A1PPP'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_2} == 'A1ZZZ'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == 'A3XXX'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "else",
"Target": "${TEST_VAR_2} == 'A3YYY'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'A2'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'A3'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_2} == 'A3PPP'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == 'A3ZZZ'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == 'A3XXX'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == 'A3YYY'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == 'A3ABC'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'B1'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'B2'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'B3'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***C***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'C'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***D***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'D'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***E***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'E'",
"Value": ""
},
{
"Command": "comment",
"Target": "***F***",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'F'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "***G to L***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1_FIRST_CHAR} == 'G' || ${TEST_VAR_1_FIRST_CHAR} == 'H' || ${TEST_VAR_1_FIRST_CHAR} == 'I' || ${TEST_VAR_1_FIRST_CHAR} == 'J' || ${TEST_VAR_1_FIRST_CHAR} == 'K' || ${TEST_VAR_1_FIRST_CHAR} == 'L'",
"Value": ""
},
{
"Command": "comment",
"Target": "***G***",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_1} == 'G'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***H***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'H'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***I***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'I'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***J***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'J'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***K***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'K'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***L***",
"Value": ""
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "***M to R***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1_FIRST_CHAR} == 'M' || ${TEST_VAR_1_FIRST_CHAR} == 'N' || ${TEST_VAR_1_FIRST_CHAR} == 'O' || ${TEST_VAR_1_FIRST_CHAR} == 'P' || ${TEST_VAR_1_FIRST_CHAR} == 'Q' || ${TEST_VAR_1_FIRST_CHAR} == 'R'",
"Value": ""
},
{
"Command": "comment",
"Target": "***M***",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_1} == 'M'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***N***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'N'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***O***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'O'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***P***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'P'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***Q***",
"Value": ""
},
{
"Command": "comment",
"Target": "***R***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'R'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'S'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***T***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'T'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***U***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'U'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***V***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'V'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***W***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'W'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'X'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***Y***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'Y'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "***Z***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == 'Z'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "***0 to 9***",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1_FIRST_CHAR} == '0' || ${TEST_VAR_1_FIRST_CHAR} == '1' || ${TEST_VAR_1_FIRST_CHAR} == '2' || ${TEST_VAR_1_FIRST_CHAR} == '3' || ${TEST_VAR_1_FIRST_CHAR} == '4' || ${TEST_VAR_1_FIRST_CHAR} == '5' || ${TEST_VAR_1_FIRST_CHAR} == '6' || ${TEST_VAR_1_FIRST_CHAR} == '7' || ${TEST_VAR_1_FIRST_CHAR} == '8' || ${TEST_VAR_1_FIRST_CHAR} == '9'",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_1} == '123'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == '1234'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_1} == '12345'",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${TEST_VAR_2} == '12345PPP'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == '12345ZZZ'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "elseif",
"Target": "${TEST_VAR_2} == '12345XXX'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${!statusOK} == true",
"Value": ""
},
{
"Command": "pause",
"Target": "0",
"Value": ""
},
{
"Command": "if_v2",
"Target": "${!statusOK} == true",
"Value": ""
},
{
"Command": "pause",
"Target": "0",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "elseif",
"Target": "${!statusOK} == false",
"Value": ""
},
{
"Command": "pause",
"Target": "0",
"Value": ""
},
{
"Command": "elseif",
"Target": "",
"Value": ""
},
{
"Command": "pause",
"Target": "0",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "else",
"Target": "${TEST_VAR_2} == '12345YYY'",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "else",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "ERROR",
"Value": ""
},
{
"Command": "echo",
"Target": "Please check TEST_VAR_1 value.",
"Value": "#shownotification"
},
{
"Command": "comment",
"Target": "insert sub processes here",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
}
]
}```