Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

HELP - removeRepeatingRow( RowID ) Sheet Worker Script function not working

Howdy all, I'm working with a sheet worker script that dynamically adds/removes rows from repeating sections on the "display" page of the character sheet whenever rows are added/removed on the "data input" page of the character sheet. I've been able to dynamically add rows easily, but removing rows has proven difficult. In my testing, I'm able to retrieve the row IDs of the rows I need to delete, but passing those IDs to the delete function doesn't seem to do anything. The relevant section of my test-case worker script is this: getSectionIDs("repeating_cldisps", function(idarray) { for(var i=0; i < idarray.length; i++) { setAttrs({ role: idarray[i] }); removeRepeatingRow( idarray[i] ); } }); "role" is an unused variable on my sheet that I'm just spitting the row IDs out to--checking my sheet after this worker script executes shows me that "role" gets assigned a valid rowID, but the call to removeRepeatingRow() still isn't doing anything. What am I missing? Here's my full test-case function: //Latch the size of the respective repeating sections on('sheet:opened',function(){ getSectionIDs("repeating_cls", function(idarray) { getSectionIDs("repeating_cldisps", function(idarray2) { self.skillobj = self.skillobj || {}; self.skillobj.inputval = idarray.length; self.skillobj.dispval = idarray2.length; var diff = 0; var input = self.skillobj.inputval; var disp = self.skillobj.dispval; if(input > disp) { var diff = input - disp; for (i = 0; i < diff; i++) { var newrowid = generateRowID(); var newrowattrs = {}; newrowattrs["repeating_cldisps_" + newrowid + "_dispcommonlorenames"] = "test" newrowattrs["repeating_cldisps_" + newrowid + "_dispcommonlorescores"] = 11; setAttrs(newrowattrs); } } else if (disp > input){ var diff = disp - input; getSectionIDs("repeating_cldisps", function(idarray) { for(var i=0; i < idarray.length; i++) { setAttrs({ role: idarray[i] }); removeRepeatingRow( idarray[i] ); } }); } }); }); });
1494269730
Jakob
Sheet Author
API Scripter
You need to run removeRepeatingRow("repeating_cldisps_" + idarray[i]); instead.
Jakob, Thanks! That worked. I'm a bit confused though--is the roll20 wiki incorrect? Their example functions is as follows: on("change:repeating_inventory", function() { getSectionIDs("repeating_inventorysummary", function(idarray) { for(var i=0; i < idarray.length; i++) { removeRepeatingRow( idarray[i] ); } }); });
1494314756
Jakob
Sheet Author
API Scripter
Yes, the example seems to be incorrect, although the text above it is correct. I'll fix it quickly.