Common runtime problems

The four main common runtime problems are; invalid number of arguments in a function call, invalid argument type, mismatched argument types in comparisons, and XML parsing.

Invalid number of arguments in a function call
Compiled IBM® Product Master scripts must call functions with the exact number of arguments that they take. You cannot rely on defaulting to null for non-specified parameters.
Invalid argument type
The wrong type of argument is being passed to a function. For example, a HashMap argument is being passed to a function that requires a String. This problem also happens if Product Master cannot infer the type correctly; you need to use the checkString() script operation.
Mismatched argument types in comparisons
If you do not have the same data type on both sides of a conditional operator such as ==, >, <, and <= then the expression evaluates to false. This evaluation does not result in an error message, but the corresponding code will not be run. For example, the following script will not work:
var id = "12345";

var my_id = item.getEntryAttrib(path to some attribute that is a sequence) ; 

if ( id == my_id) {

// statements that need to be executed but will not be 

} 

The solution in this case is to explicitly use: 

var id = "12345" ; 

var my_id = checkString(item.getEntryAttrib(//some attribute that is a sequence),) ; 

if ( id == my_id) { 

// statements to be executed 

} 
XML parsing
The following code seems to work in non-compiled mode and even in compiled mode when run from the sandbox:
new XmlDocument(xmlDoc) ; 

forEachXmlNode("item") { 
} 
However, in compiled mode, if this code is used in a script library function that is started by multiple users, then the statements inside the forEachXmlNode script operation block do not get run. There is no error message. The workaround is to use the following code:
var doc = new new XmlDocument(xmlDoc) ; 

var xmlNode ; forEachXmlNode(doc, "item", xmlNode) { 
}