I know this has been talked about on here quite a bit before, but I guess I am still not understanding it and I need some help. I am trying to have some attrs outside of a repeating section update the attrs inside of the repeating section. I understand I need to use getSectionIDs and feed the resulting IDs into the names of the repeating sections attrs. I just can't quite figure out how to do this to be used by the setAttrs function. I have been able to narrow it down to the setAttrs function not working. Everything else seems to be ok. Anyone think they can help? FYI: 'repeating_moves_moveattr' is a select field that I am using inside the repeating section to choose a mod value. The mods and 'helpdice' exist outside the section. on('sheet:opened change:helpdice change:fightmod change:movemod change:talkmod change:searchmod change:weirdmod change:mettlemod',
function(){
console.log('====> change for attributes <====');
getAttrs([
"fightmod",
"movemod",
"talkmod",
"searchmod",
"weirdmod",
"mettlemod"
], function(values) {
var mods = [
values.fightmod,
values.movemod,
values.talkmod,
values.searchmod,
values.weirdmod,
values.mettlemod
];
getSectionIDs('repeating_moves',function(ids){
_.each(ids,function(id){
getAttrs([
"repeating_moves_"+id+"_moveattr",
"repeating_moves_"+id+"_movemoda",
"helpdice"
], function(values){
var currentmoveattr = "repeating_moves_"+id+"_moveattr";
var currentmovedice = "repeating_moves_"+id+"_movedice";
var currentmovemoda = "repeating_moves_"+id+"_movemoda";
setAttrs({
currentmovedice: Math.floor(mods[parseInt(values.currentmoveattr)] + parseInt(values.currentmovemoda) + parseInt(values.helpdice))
});
});
});
});
});
});
********** EDIT: To anyone coming here looking how to do this ************ Replace the 3 'setAttrs' lines above with this: let attrs = {};
attrs[currentmovedice] = parseInt(mods[parseInt(values[currentmoveattr])]) + parseInt(values[currentmovemoda]) + parseInt(values.helpdice);
setAttrs(attrs); What this does is create a new object array called "attrs". Within that is an object called 'currentmovedice', which we defined earlier by creating the string and using the id from 'getSectionIDs'; and we are pairing that with the new formula. We are then running the function 'setAttrs' on the new object array, which really only includes the one 'currentmovedice' object. The formula is using the " values[*****] " format instead of the " values.**** " format so we can use the other strings we defined earlier using the id from 'getSectionIDs'.