Page 1 of 1

Error reading XML file

Posted: Tue Jun 20, 2017 8:01 pm
by vikas
Hi Plum

I am getting below error when reading an XML file in our Preprod environment.
Code is saved as "SafewayAutomation" in scratchpad. It is assigned to 855-606-3493.

I have verified the Javascript code in other editors and cannot find a reason why I am getting this error in Plum Voice.
TypeError: records has no properties

Re: Error reading XML file

Posted: Wed Jun 21, 2017 12:40 pm
by support
Hi Vikas,

It appears as though you are receiving this error because the JavaScript DOM version supported in our hosting site does not support the square bracket notation for iterating through objects. Instead, you should use the item() method. We were able to return "yahoo" by changing the following in your scratchpad:

Code: Select all

for (i = 0; i < records.length; i++) {
	if (records.item(i).childNodes.item(0).toString() === ani) {
			return ('yahoo');
	}
}
Note that we also added the toString() method since you are using the === operator for comparison, which does not perform type conversions. Since the item() method returns an object, but the ani variable in your code is a string, this comparison would evaluate to false without the toString() method, even if the two numbers were identical.

Regards,
Plum Support

Re: Error reading XML file

Posted: Wed Jun 21, 2017 1:33 pm
by vikas
Thanks a lot. That worked