Bunty11
Hot Shot
Hot Shot

vRO Error

Jump to solution

I am getting below error when running my workflow in vRO

"" TypeError: Cannot call method "indexOf" of null (Workflow:Alerts / (item2)#9)'   ""

unable to find out what error it is exactly ?

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

This error means that on line 9 in workflow item with ID item2 you have a code that looks something like the following:

var result = somestring.indexOf("something");

and that the object on which indexOf() method is invoked (somestring in the code above) has a null value, causing the exception to be thrown at runtime.

Now, why the value is null is hard to say. Maybe you forgot to bind it as an input taking its value from previous workflow item. Or the variable may not be initialized properly. Or could be something else. I'd suggest to instrument your workflow scripting code with additional System.log() statements to trace what exactly is happening at runtime.

View solution in original post

4 Replies
daphnissov
Immortal
Immortal

Unless you show us your code we cannot help you.

0 Kudos
iiliev
VMware Employee
VMware Employee

This error means that on line 9 in workflow item with ID item2 you have a code that looks something like the following:

var result = somestring.indexOf("something");

and that the object on which indexOf() method is invoked (somestring in the code above) has a null value, causing the exception to be thrown at runtime.

Now, why the value is null is hard to say. Maybe you forgot to bind it as an input taking its value from previous workflow item. Or the variable may not be initialized properly. Or could be something else. I'd suggest to instrument your workflow scripting code with additional System.log() statements to trace what exactly is happening at runtime.

Bunty11
Hot Shot
Hot Shot

Thank You for your help.

Below line was in my code . and PSOUTPUT is going as NULL. Therefore i am getting the error.

if(psOutput.indexOf("Error In Operation") == -1)

Have you passed Powershell output from Workflow item to another ?

How did you passed the Powershell output ??? I mean the PSOUTPUT Variable that we are passing should be declared as string ??

0 Kudos
iiliev
VMware Employee
VMware Employee

Your scripting code looks fine. What you can do as a quick patch is to just add one additional if() check for psOutput value being null in order to not use it in expressions like psOutput.indeOf() that would throw an error if the object is null.

I'm not familiar enough with the plug-in to say whether a null value is valid/expected as a result from method getHostOutput(). If a null value is the normal result when the invoked script produces no output, then the null check suggested above is the proper thing to do.