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

[Sheet Worker Scripts] Getting the values of only the topmost repeating section

1511973831
Missingquery
Pro
Sheet Author
API Scripter
I have seen several threads about getting the attributes from a repeating section, however, I haven't been able to find how to grab the attributes from only the topmost repeating section. Obviously, I can't use static IDs to identify the topmost section, but I genuinely have no idea how to do so. Additionally, I asked this a while ago, but I was also wondering if it is possible to conditionally disable or style input fields in Roll20 using Sheet Worker Scripts. That's not a top priority for me, but I would like to know.
1511980981
Lithl
Pro
Sheet Author
API Scripter
By "topmost repeating section", do you mean the first item in a repeating section? You use $0 instead of the ID. (or $1 for the second item, $2 for the third, etc.) For conditionally styling input fields, you can take the same concept used in  Hide Areas to change their style, and you could use sheet workers to set the value of an invisible checkbox to base the style toggling on. Note that if you want to style the input based on the input's value, the sheet worker won't fire until the input loses focus, so you can't get updates as-you-type.
1511981210
Missingquery
Pro
Sheet Author
API Scripter
That helps a lot. Thank you!
1511987555
Jakob
Sheet Author
API Scripter
Are you asking how to get the values of the topmost section in sheet workers, or in a macro? Those two approaches would need very different techniques...
1511990815
Missingquery
Pro
Sheet Author
API Scripter
In sheet workers, yes.
1512028137

Edited 1512028235
Jakob
Sheet Author
API Scripter
Okay, so you'll have to utilize the _reporder attribute to get the ID of the topmost repeating section. In the wiki , there's a getSectionIDsOrdered function that you could use, which works like getSectionIDs except that the order of the IDs in the array given to the callback is actually the order displayed on the sheet. So idArray[0] will give you the ID of the first row if you use getSectionIDsOrdered. Obviously, if you only need the first row, you can do it faster, but I don't think it makes much of a difference here.