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 : Call sheetworker on repeating item creation.

Hello everyone Here is my problem : I have some fields in a repeating section that have to be computed by a sheetworker. They depend on some field that have default values defined. If these default values are never changed, then my worker is never called. Is there any way to call a sheetworker when a repeating item is created ? Somehow, I have not found any way to do this, only a way to call the worker when an item is removed. Thanks
1597597117
GiGs
Pro
Sheet Author
API Scripter
I dont think there is a direct way to do this, weirdly enough. The easiest way to do this is to have a select in the repeating section, with one of the options set to selected. Then in your sheet worker, check for changes in that attribute. When a new row is created, that item will be set, and the change event will fire. A checkbox set to checked would likely work too, though I've never done it that way. That could be set to display:none,  and just used for this purpose.
1597599416
GiGs
Pro
Sheet Author
API Scripter
Also, another thing - if you have a bunch of default values in your section, just set the default value of anything that needs to be calculated to match those defaults. That way when creating a new row, you dont need to have a sheet worker fire - everything is already correct. You only need to check when things actually change.
1597600108
vÍnce
Pro
Sheet Author
Pardon my ignorance, but isn't a "change" detected when a repeating row is created?  ie "change:repeating_spells"
1597601314
GiGs
Pro
Sheet Author
API Scripter
The row isnt actually created when you click the ADD button - only when you change something in the row. Try this: on a sheet, click the add button, then click somewhere else on the sheet and change something, without doing anything with the repeating section. The row you just added will vanish. It hasnt actually been created. Note: many sheets have some selected or checked values creating values, that will set a value and cause the row to be created. So make sure you test this on a sheet with a very simple repeating section - equipment lists are usually good for this.
1597601738
vÍnce
Pro
Sheet Author
GiGs said: The row isnt actually created when you click the ADD button - only when you change something in the row. I knew that. lol ;-) Thanks GiGs.