I am trying to rewrite this function: RepeatingSum - Roll20 Wiki to return the value instead of writing it to an attribute. I managed to get it working however it requires a global variable to function, which I cant update unless the sheet is closed and reopened. My function call: var sum_test = repeatingSumReturn('characteristics','characteristic_spending_str_extra') console.log(sum_test); this works when I manually return a 1 in the function. This function isn't working. I cant figure out how to return the sumTotal as returning it in the getAttrs doesn't return the value. var sumTotal = 0; const repeatingSumReturn = (section, fields, multiplier = 1) => { var sumTotal = 0; if (!Array.isArray(fields)) fields = [fields]; getSectionIDs(`repeating_${section}`, idArray => { const attrArray = idArray.reduce( (m,id) => [...m, ...(fields.map(field => `repeating_${section}_${id}_${field}`))],[]); getAttrs(attrArray, v => { // getValue: if not a number, returns 1 if it is 'on' (checkbox), otherwise returns 0.. getValue = (section, id,field) => parseFloat(v[`repeating_${section}_${id}_${field}`]) || (v[`repeating_${section}_${id}_${field}`] === 'on' ? 1 : 0); sumTotal = idArray.reduce((total, id) => total + fields.reduce((subtotal,field) => subtotal * getValue(section, id,field),1),0); console.log("Sum1= "+ sumTotal); }); }); console.log("Sum1= "+ sumTotal); return sumTotal // return 1 //This was a test and worked, somehow I need to grab the sum total value }; my console log: Sum2= 0 0 Sum1= 13