
I’m trying to reorder a repeating section ( repeating_weapons ) whenever a checkbox ( attr_weapon_checkbox ) is checked or unchecked. The goal is simple: Checked items should move to the top. Unchecked items should stay below. Since I don't know javascript I've enlisted some AI help but we're constantly running into a problem. I've incorporated the script into the sheet's HTML in the <script> section. However, the console logs confirm that: The script detects checkboxes correctly. The items are sorted in the correct order. But setSectionOrder("repeating_weapons", sortedArray); does not visually update the list —items remain in the same order as before. Here is the most basic version of the script, before we tried about a dozen ways to trick/force it to work: on("change:repeating_weapons:weapon_checkbox remove:repeating_weapons", function() { getSectionIDs("repeating_weapons", function(idArray) { let attributes = idArray.map(id => `repeating_weapons_${id}_weapon_checkbox`); getAttrs(attributes, function(values) { let checkboxState = {}; idArray.forEach(id => { checkboxState[id] = values[`repeating_weapons_${id}_weapon_checkbox`] === "on" ? 1 : 0; }); console.log("Checkbox states:", checkboxState); let sortedArray = idArray.sort((a, b) => checkboxState[b] - checkboxState[a]); console.log("Weapon IDs after sorting:", sortedArray); setSectionOrder("repeating_weapons", sortedArray); }); }); }); I also see the console error: "Character Sheet Error: Trying to do setSectionOrder when no character is active in sandbox." My questions: Does setSectionOrder() require something specific to work? Is Roll20 blocking setSectionOrder() due to a "pre-defined key order" error? Is there another way to move checked items to the top of the list? Any guidance is appreciated! Thanks in advance. And yes I understand AI is prone to errors or hallucinations , but it's what I have to work with without bothering nice humans like you all the time. :) I'm just trying to do the best I can without constantly posting in the forum for help, so if there are glaring errors in the code, I apologize. Again, thank you very much for your help and patience.