Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Object doesn't support this property or method

Hi All,

I am getting an error that says "Object doesn't support this property or method"

It points to this line return ary.filter(function(elem) {  

	 $().SPServices({
	    operation: "GetListItems",
		listName: "Projects",
		async: false,
		CAMLViewFields: "<ViewFields><FieldRef Name='SiteProjectedAmount' /></ViewFields>",
		CAMLQuery: cml,
		CAMLRowlimit:100,
		completefunc: function (xData, Status) {	
		//alert(xData.responseXML.xml);
		$(xData.responseXML).find("z\\:row").each(function () {		
				var ProjectItem = new Object();
				ProjectItem["AmountProjected"] = checkForUndefined($(this).attr("ows_SiteProjectedAmount"));
				ProjectItem["ProjectNumber"] = $(this).attr("ows_ProjectNumber");
		
				AnnualizedDataArray.push(ProjectItem);
				/*var x = checkForUndefined($(this).attr("ows_SiteProjectedAmount"));
				annualCost += parseFloat(x);*/
		  });
		}
	 });
	 
var uniqBy = function(ary, key) {
    var seen = {};
    return ary.filter(function(elem) {
        var k = key(elem);
        return (seen[k] === 1) ? 0 : seen[k] = 1;
    })
}

uniqs = uniqBy(AnnualizedDataArray, JSON.stringify);
values = uniqs.map(function(x) { for(var k in x) return x[k] });
annualCost = values.reduce(function(a, b) { return a + b });

Open in new window


It works in jsfiddle. http://jsfiddle.net/GTpgA/41/

Any ideas?

Thanks!
Avatar of Rob
Rob
Flag of Australia image

What javascript framework are you using?  in your fiddle you're using mootools but this topic is listed at jQuery.  jQuery has its own filter function that may interfere but I'm suspecting after a bit of testing (changing your fiddle to use jQuery then no framework and it's still working) that the actual error is elsewhere in your code.

I would output to the console (console.log() instead of alert, you'll see more) the contents of AnnualizedDataArray before the uniqBy function, for instance to see if the data is in the format you expect.
Avatar of Isaac

ASKER

What's the best way to see what's in an array?  This is all being done in SharePoint which is really a web page.
If you use console.log() it will dump the contents of the stay to the console. You can get to the console vis the developer tools by pressing f12
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial