Hi Lova... I think your two goals are best carried out in different domains. Having dropdowns on the sheet that modify another field in the same repeating element... that is something best handled with sheetworkers.
Getting the total of all rows (or a subset) is possible from either the sheet side or the API side... you just have to go through a few steps. Let's say you have a repeating section for "Weapon Skills". You probably know, from building your sheet, that such a section would have a name like:
repeating_weaponskills
Let's imagine every "entry" in that list would have several elements under it:
weapon_name
material_bonus
encumbrance_mod
quality_bonus
offhand_penalty
description
Those are each individual attributes with their own unique ID. And even though we reference them by how they relate to the element that links them, to the API they are stored in a flat set. It isn't like we identify an item in the repeating list, then drill down off of that to a tree of properties with dot notation. Instead, we get them by the way they include an ID for the item set in their name:
repeating_section_repID_suffix
--for instance...
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_weapon_name
All of the attributes connected to the single item in the repeating list will have the same form (including the same repID), up to the suffix:
Attribute Name | Current
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_weapon_name | Wet Carp
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_material_bonus | 0
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_encumbrance_mod | -1
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_quality_bonus | 1
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_offhand_penalty | -1
repeating_weaponskills_-M3n0XLcCSqTxaf4Ldq3_description | Blessed by Ba'ag the Lesser, discovered at the end of the last age
Orange. Smelly. Approximately 5lbs. Speaks occasionally.
That means to total what we want to total, we have to be able to 1) identify the item from the list, 2) extract the repID from the name, 3) get all of the element attributes associated with the item, and 4) total the appropriate element attributes (based on the suffix(es) supplied).
Regex
The following regex represents the breakdown of each of those components:
let fullrx = /^repeating_([^_]*?)_([^_]*?)_(.+)$/;
// FROM : repeating_section_repID_suffix
// group 1: section
// group 2: repID
// group 3: suffix
If you have any given portion, you can substitute it into the regex as necessary. Here is a regex where you know the section (in a variable called "section"):
let sectionrx = new RegExp(`^repeating_${section}_([^_]*?)_(.+)$`, 'g');
// FROM : repeating_section_repID_suffix
// group 1: repID
// group 2: suffix
And another where you know the suffix of the element that is naming the item in the list (in a variable called "sfxn"):
let itemrx = new RegExp(`^repeating_${section}_([^_]*?)_${sfxn}$`, 'g');
// FROM : repeating_section_repID_suffix
// group 1: repID
Identification and Extraction of repID
Use one of those regex statements to isolate the repeating element and extract the ID. Here, I pretend I have the section and the naming suffix, so I'll use the itemrx (above), and I'll filter where it equals "Wet Carp"... (I also have the character in an object named "chr"):
let attr = findObjs({ type: 'attribute', characterid: chr.id })
.filter(a => itemrx.test(a.get('name')))[0];
if (!attr) // ... error handling goes here
let repID = itemrx.exec(attr.get('name'))[1];
Get Element Attributes and Total Where Appropriate
Now that you have the repID, you can return all of the attributes for this character from that list where they match the repID (in other words, all of the element attributes for this item in the repeating list).
Obviously you don't want to total the name or description fields, only the fields that have values appropriate to the number you are trying to represent. For instance, a weapon might have a "walking around" modifier of the total of the material mod, the encumbrance penalty, and the quality bonus. If a character happened to be trying to wield the weapon in her off-hand, then you would want to also include the off-hand penalty.
If you put the suffixes of the attributes you want to include (to arrive at the "walking around" mod) in an array, you can use the array to drive a test and sum as appropriate.
let sumsfxs = ['material_bonus', 'encumbrance_mod', 'quality_bonus']; // array of suffixes to total
let elemrx = new RegExp(`^repeating_${s}_${repID}_.*`); // regex using the repID
let modtotal = findObjs({ type: 'attribute', character: chr.id }) // get all attributes for this character
.filter(a => elemrx.test(a.get('name'))) // filter for only those in this repeating item
.reduce((m,a) => {
return sumsfxs.some(b => a.get('name').includes(b)) ? m + Number(a.get('current')) : m;
},0);
The reduce() function, above, builds a sum for those attributes who have a name that contains an element from the array of naming suffixes you supplied (sumsfxs). If the name passes, we include it in the sum.