Retrieve Values from CAML Query Array
I am trying to retrieve specific array values for the following CAML query.
The CAML Query works - but I'm unable to obtain the actual values for the field "Points_x0020_Completed". How do I access the array X so I can sum up all values in the field "Points completed"?
=============================================================
var varSum = 0;
var x = [[@Site.QueryList("My Site", "<Query><Where><Eq><FieldRef Name=\"Scrum_x0020_Team\" ></FieldRef><Value Type=\"Choice\">[[Scrum_x0020_Team]]</Value></Eq></Where></Query>", 10, "Points_x0020_Completed", "GRID")]];
for (var i = 0; i < x.length; i++) {
if (x[i][i] >= 0) varSum = varSum + x[i][i];
}
return varSum;
-
Hi Marc Bernard,
you could use the GetValuesForQuery function on the web context object like this:
var varSum = 0;
var x = [[@Web.GetValuesForQuery("yourlistname", "<Where><Eq><FieldRef Name=\"Scrum_x0020_Team\" ></FieldRef><Value Type=\"Choice\">[[Scrum_x0020_Team]]</Value></Eq></Where>", "Points_x0020_Completed")]];
for (var i = 0; i < x.length; i++) {
if (x[i] >= 0) varSum = varSum + x[i];
}
return varSum;Simply replace the parameter "yourlistname" with yours.
Cheers Matthias
0
Please sign in to leave a comment.
Comments
1 comment