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 workers] getAttrs returns undefined for empty attributes

1511021325
Jakob
Sheet Author
API Scripter
When an attribute object exists, but the value of that attribute is an empty string, getAttrs will return undefined for the attribute, no matter what the default value is. <input type="checkbox" name="attr_start_test"> <input type="text" name="attr_test_nodefault" value=""> <input type="text" name="attr_test_default" value="default"> <script type="text/worker"> on('change:start_test', () => { getAttrs(['test_default', 'test_nodefault'], v => log(v)); }); </script> If you set the text inputs to some nonempty value, then clear them and tick the checkbox, both v.test_default and v.test_nodefault are undefined. This is not the case in the initial state of the sheet - when no attribute objects exists, it correctly logs "" and "default".
1512420203
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
Jakob I looked into this inconsistancy. There should be a fix to handle the exception of a blank string value not falling back on the default that goes out tomorrow. 
1512978341
Jakob
Sheet Author
API Scripter
I can confirm that this has been fixed now, thanks Steve!