Hi, I'm still working out how to write sheetworkers for a character sheet that I'm hoping will go to the community github. I've had trouble using getAttrs inside a for loop. I'm trying to work through each entry in a repeating fieldset, grab the value of the "attr_college" field, and concatenate them all together, so that I can test if they are all empty or not. When I run this, getAttrs seems to run AFTER the for loop, so only the last use of v[...] has an entry and the previous ones are all returned as undefined. Is this the intended behaviour? If so, how can I work with the values of a field in a repeating fieldset (e.g. checking their blank, getting a total)? The code that is giving me trouble is: on("change:repeating_college remove:repeating_college", function() {
getSectionIDs("repeating_college", function(idArray) {
if(idArray.length == 0) {
// Do one thing
}
else {
console.log(idArray);
var concat = "";
for (var i=0; i < idArray.length; i++) {
var idname = idArray[i];
console.log("attrname: " + "repeating_college_" + idname + "_college");
getAttrs(["repeating_college_" + idname + "_college"], function(v) {
console.log(v["repeating_college_" + idname + "_college"]);
concat += v["repeating_college_" + idname + "_college"];
console.log("concat: " + concat);
});
}
}
});
});
Many thanks!