I'm attempting to combine a repeating fieldset that will not be used (it is removed from the new sheet) to an existing fieldset that is kept when the sheet is updated. Old fieldset is called repeating_inventtab2 and will not exist on the new sheet. Current fieldset is called repeating_inventtab1 It is not working so I'm trying to understand what am I doing wrong. old sheet worker that was given to me. on("sheet:opened", function() { // Make a list of some attributes on the old sheet that are not on the new sheet, it doesn't have to be all of them. // Just make sure you list at least most of the attrs that are commonly used, like primary stats or whatever. // This will check if any of these attrs exist, if they do you know that this used to be the old sheet. // Make sure to add the attr 'already_transitioned' to the list getAttrs(['list', 'of', 'attrs', 'on', 'the', 'old', 'sheet', 'already_transitioned'], function(attrs) { if(attr.already_transitioned !== '1') { var hasOldData = false; var updates = {}; _.each(attrs, function(value, key) { // loop through the list and see if they exist if(value) { hasOldData = true; } }); if(!hasOldData) { // It's not the old sheet, mark already_transitioned so that we don't ever do the loop again. updates.already_transitioned = '1'; setAttrs(updates); } else { // We know this used to be the old sheet, now we need a list of EVERY attribute you want to copy getAttrs(['list', 'of', 'all', 'attrs', 'on', 'the', 'old', 'sheet'], function(oldAttrs) { // for each attribute, on the left you have the name of the attribute on the new sheet // and on the right you have the name of the attribute on the old sheet updates.newSheetValue1 = oldAttrs.list; updates.newSheetValue2 = oldAttrs.of; updates.newSheetValue3 = oldAttrs.all; updates.already_transitioned = '1'; setAttrs(updates); }); } } }); }); My sheetworker // Transitioning from old sheet to new sheet.
on("sheet:opened", function() {
// Make sure to add the attr 'already_transitioned' to the list
getAttrs(['repeating_inventtab2', 'already_transitioned'], function(attrs) {
if(attr.already_transitioned !== '1') {
var hasOldData = false;
var updates = {};
_.each(attrs, function(value, key) { // loop through the list and see if they exist
if(value) {
hasOldData = true;
}
});
if(!hasOldData) { // It's not the old sheet, mark already_transitioned so that we don't ever do the loop again.
updates.already_transitioned = '1';
setAttrs(updates);
}
else {
// We know this used to be the old sheet, now we need a list of EVERY attribute you want to copy
getAttrs(['repeating_inventtab2'], function(oldAttrs) {
// for each attribute, on the left you have the name of the attribute on the new sheet
// and on the right you have the name of the attribute on the old sheet
updates.repeating_inventtab1 = repeating_inventtab2;
updates.already_transitioned = '1';
setAttrs(updates);
});
}
}
});
});