Isaac
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) {
It works in jsfiddle. http://jsfiddle.net/GTpgA/41/
Any ideas?
Thanks!
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 });
It works in jsfiddle. http://jsfiddle.net/GTpgA/41/
Any ideas?
Thanks!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.